
For this week’s challenge, Lorna asked us to complete the challenge by not using LoDs or Table Calcs. Parameters and parameter actions were necessary though (originally I started without using them either, as I misread the information).
Building the core bar chart
As mentioned, we’re going to use parameters to capture the info we need. So start by creating
pSelectedSubCat
string parameter to store the name of the Sub-Category selected – default to Storage

pSelectedSales
float parameter to store the Sales value of the selected sub category. Set this to 224,645 which is the value associated to Storage and set the display format to $ with 0dp.

The plan is that when ‘No Comparison‘ is selected, the pSelectedSubCat will contain nothing ie an empty string of ” “, and pSelectedSales will be 0.
Based on this, we need to define the value to display in the bar, which typically is the difference between the Sub-Category sales and the sales of the pSelecedSubCat (ie the value in pSelectedSales). But in the event No Comparison is selected, we just want the sales. So create
Difference
IIF([pSelectedSales]>0,SUM(Sales)-[pSelectedSales],SUM([Sales]))
is if we have a value in pSelectedSales, return the difference between the Sales value and it, otherwise just return Sales.
Set a custom number format of “$”#,##0;-“$”#,##0;””
Note the last setting after the 2nd “;” is the formatting for a 0 – in this case I’ve set it to ” ” ie nothing/<empty string>, so a value won’t get displayed against the bar of the selected Sub Category
Add Sub-Category to Rows and Difference to Columns. Explicitly sort the Sub–Category pill to be sorted by Sales descending

Show mark labels, and widen the bars a bit. Adjust bar colour as required. Add a column grand total, and display at the top (Analysis menu > totals > show column grand totals, then Analysis menu > totals > column totals to top)

We’ve done this as we need the additional row at the top of the chart to align with the ‘No Comparison’ option in the selector we’ll build, but we don’t want the bar to show. To get rid of it, click on the bar and then select Hide from the ‘automatic’ drop down

which gives us

Hide the Sub-Category row heading and axis (uncheck show header from the pills). Remove all gridlines, row/column dividers and axis rulers/zero lines etc.

We’ll come back to this sheet later.
Building the selector sheet
We’re going to build this using a dual axis of a bar chart and a shape.
On a new sheet, add Sub-Category to Rows and again sort by Sales descending.
Double click into Columns and type MIN(-1.0)
Change the mark type to bar and widen each row a little. As before, add Column Grand Totals to the top.

Create a new field
LABEL: Sub Cat
IF MIN([Sub-Category])<>MAX([Sub-Category])
THEN “No Comparison” ELSE ATTR([Sub-Category])
END
If we just add Sub-Category to the label, the grand total row will show as ‘All’. The above is a sneaky way to change the word ‘All’, as in the ‘grand total’ row, all the Sub-Categories are ‘known about’, so the MIN(Sub-Category) and MAX(Sub-Category) are different.
Add this field to the Label shelf, and align left centre (the axis is -ve, so the alignment has to be to the left, even though it’s displayed on the right).

We need to be able to identify which row (including the grand total row) has been ‘selected, so create
Is Selected SubCat
ATTR([Sub-Category]) = [pSelectedSubCat] OR ([pSelectedSubCat]=” AND [LABEL: Sub Cat ] = ‘No Comparison’)
And add this to Colour, and colour the True to match the bar chart colour you chose, and Null and False to white (so it ‘disappears)

Now create a secondary axis by double clicking into Columns and type MIN(-0.9). Change the mark type to Shape. Remove Label: SubCat from the marks card. Create a duplicate of Is Selected SubCat so you have Is Selected Subcat (copy) and add this field to shape and to Colour and set the colour and shape as required

Make the chart dual axis and synchronise the axis. Hide all the axis and the row headings and remove all row/column dividers, gridlines etc.

Building the dashboard and adding the interactivity
Create a dashboard and using a horizontal layout container arrange the Selector sheet and the Bar sheet side by side, ensuring both ‘fit entire view, which will make sure the rows all align with each other.

We need to change the values of the pSelectedSubCat and pSelectedSales parameters on click of either chart. When we do this, we need to pass the relevant values into the parameter. Because we also have to handle the ‘grand total’ row, we need some additional fields for this
Sub Cat for Param
IIF([LABEL: Sub Cat ]=’No Comparison’,”,ATTR([Sub-Category]))
ie use ‘nothing if the ‘grand total’ is clicked, otherwise use the Sub-Category
similarly
Sales for Param
IIF([LABEL: Sub Cat ]=’No Comparison’,0,SUM([Sales]))
ie use 0 f the ‘grand total’ is clicked, otherwise use the Sales value of the Sub-Category
Add both these pills to the Detail shelf of the All marks card on the Selector sheet, and to the Detail shelf on the Bar sheet.
On the dashboard, create a dashboard parameter actions
Set Sales Value
On select of either sheet, set the pSelectedSales parameter, passing in the value from the Sales for Param field aggregated at the SUM level. Set to 0 when selection cleared.

Set Sub Cat
On select of either sheet, set the pSelectedSubCat parameter, passing in the value from the Sub Cat for Param field. Set to “” when selection cleared.

Finally, as we are already differentiating the ‘selection’ through different colours, we don’t want the click to ‘hihglight’ the mark. Create a new field
Dummy
“HL”
and add this to the Detail shelf on both sheets
Then create a dashboard Highlight action
Highlight
On select of either sheet, target either sheet but only with the selected Dummy field.

And that in principle should give you a functioning solution. The only extension I made, as to make the Tooltips on the bar chart make sense depending on what was being viewed. This involved building up a series of Tooltip Text fields. Check out my solution if you need to see the details.
My published viz is here
Happy vizzin’!
Donna





























































































































