
The focus of this week’s challenge, set by Yoshi, is showing “detail on demand” using filters.
Defining the calculations
We’re only concerned about current year and previous year, so to simplify this, after connecting to the data source, I added a data source filter based on Order Date to restrict the information to years 2023 and 2024 only.

I then created the following fields
Latest Year
{MAX(YEAR([Order Date]))}
Previous Year
[Latest Year]-1
Sales – LY
IF YEAR([Order Date]) = [Latest Year] THEN [Sales] END
Format to $ with 0 dp
Sales – PY
IF YEAR([Order Date]) = [Previous Year] THEN [Sales] END
Format to $ with 0 dp
YoY
(SUM([Sales – LY]) – SUM([Sales – PY])) / SUM([Sales – PY])
Custom format to +0%;-0%;0%
Building the Sales KPIs
On a new sheet, add Category to Columns, and Sales – LY and YoY to Text and format/layout the text as required. Adjust the formatting of the column headings too.

Add YoY to Colour too to match the solution (though personally, if I was doing this for a business need, I wouldn’t do this as some of the text becomes quite washed out).

Building the Sub Category Viz
On a a new sheet, add Category and Sales – LY to Columns and Sub-Category to Rows.

However, you can see that as not every Sub-Category exists in every Category, we get ‘blanks’ in the display, so we need use something on rows that exists for every Category. We can do this using the rank of Sales.
Add Sales -LY to Rows and change it to be a discrete (blue) dimension.

Move Sub-Category to Detail and then apply a quick table calculation of rank to the Sales – LY pill on Rows. Adjust the table calculation so it is computing explicitly by Sub-Category only.

Make the rows a little wider, move Sub-Category to Label. Add Sales -LY to label too. Adjust the format/layout of label and align middle right. Add YoY to Colour.

Add Sales – PY to Detail then add a Reference Line to the Sales – LY axis, that refers to Sales – PY per cell.

Add Latest Year to Tooltip and adjust the text to suit. Finally, hide the Sales – LY Rank row header and the Category column header (uncheck show header) and remove the title of the Sales – LY axis. Add a title.

Building the Product Viz
On a new sheet, add Product Name to Rows and Sales – LY to Columns. Sort by Sales – LY descending. Hide the null value indicator.

Add YoY to Colour. Add Sales – LY to Label. Add Sales – PY to Detail and add a Reference Line as described above. Add Sub-Category to Detail and add Latest Year to Tooltip and adjust. Remove the title of the Sales – LY axis, and hide the Product Name column header title (right click and hide field labels for rows). Add a title.

Filtering the display
The requirement is to be able to ‘filter’ the display based on the Category selected, and in the event not all categories are selected, the Product bar chart should show. Due to this second requirement, just using a standard ‘quick filter’ is a bit tricky – we need a way to understand what has been selected in the filter.
We can use a Set for this. Create a set of categories – right click Category > create > set
Category Set
Select all values

Add this to the Filter shelf of the KPI sheet, and then apply this same filter to the bar chart sheets too (right click the pill on the Filter shelf > apply to worksheets > selected worksheets > select the relevant sheets).

If you select show set, this then displays the input control to select which options are in or out of the set.
To manage the visibility of the Product bar chart, we need to know how many Categories there are in total, and how many Categories are selected. So create
Count Categories
{FIXED: COUNTD([Category])}
And
Count Set Members
{ COUNTD(IIF([Category Set], [Category],NULL))}
Both of these are LODs as we need to reference them in another boolean calculation that will be used to drive dynamic zone visibility.
Not all Categories Selected
{(SUM([Count Categories]) <> SUM([Count Set Members]))}
Building the dashboard
Create a dashboard. The three sheets should be arranged within layout containers. I used a horizontal container, where the left hand column contained a vertical container which in turn contained the KPI sheet on the top and the Sub Category bar chart underneath. The right hand column of the horizontal container contained the Product bar chart.

To control the visibility of the Product bar chart, select the object, then from the Layout tab on the left hand side, select the control visibility using value checkbox, and choose the Not All Categories Selected field.

The bar will initially disappear, but if you then deselect a value in the Category ‘filter’ control, it will reappear.
Added extra
We can also set the Product bar chart to filter if a Sub-Category bar is clicked on. Create a dashboard filter action
Filter Products
On select of the Sub-Category bar chart sheet, target the Product Bar Chart sheet passing all values. Show all values when the selection is cleared.

My published viz is here.
Happy vizzin’!
Donna











































