Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
robaranieri
Regular Visitor

Sorting Calculation Group within Headers

Hi There,

 

I've got a very specific request for PowerBi Desktop. I have the following set of dummy data:

SKUWeekSalesUnitsTraffic
T3G6S19/24/2022100501300
T3G6S110/1/2022120601500
X7F5G39/24/202240280
X7F5G310/1/202220190
PPl49G79/24/2022150150600
PPl49G710/1/2022300300200

 

I am building a tracker to see week by week how sales, units, and traffic have changed. Here is report demo link:
https://drive.google.com/file/d/1K-xL6F2Km2k-ZU9XanKZ4vbTi8b6oWCS/view?usp=sharing

 

I've created measures for the current week, prior week, Delta change (Δ), and percentage change (Δ %) for each metric. 

 

The goal is to create a matrix with all the metrics with the ability to filter to a certain topic (sales, units, traffic) and with the ability to sort the table by any metric within those topics. 

 

Without calculation groups, in Table 1 I can create the output I'd want, with the ability to sort sales Δ. However, this doesn't solve the issue of needing to filter to just sales or see side by side sales with traffic for example. 
Table1.png

 

In Table 2 I can use calculation groups to create a similar output, with the ability to filter by a CalcGroup option (Sales, Units, Traffic) in order to hone in on that topic. I can even sort by a metric, but not by a metric via a topic. By that I mean I can sort by Δ, but I can't sort by Traffic Δ. I need a way to sort the matrix specifically by a specific metric within a specific topic. 

Table2.png

Images are attached to show this issue. I've read online how to sort by a calculation group, but it does include headers or multiple metrics within the group. I've used dummy data to narrow it down to 3 topics but in actuality there are about 12 total - which is why I need a way to hone them down using CalcGroups.

Below are screenshots of the TabularEditor code and the entire dashboard. 
TabularEditor.pngDashScreenshot.png

 

 

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@robaranieri,

 

Try this solution that utilizes a fields parameter. Each measure needs to be created, since a calculation group doesn't seem to allow sorting on a specific column as you indicated.

 

1. Create the table Topic with each topic and its associated measure names:

 

DataInsights_0-1666278315524.png

 

2. Create a fields parameter with each measure listed in the table above. Uncheck "Add slicer to this page".

 

DataInsights_1-1666278361710.png

 

3. Create a relationship between Topic and TopicParameter. The default is bidirectional, but I changed it to unidirectional (I avoid bidirectional relationships whenever possible).

 

DataInsights_2-1666278408895.png

 

4. Create a matrix and add TopicParameter to the Values field well:

 

DataInsights_3-1666278527846.png

 

5. Create a slicer using Topic[Topic].

 

6. Sort by any matrix column:

 

DataInsights_4-1666278588968.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
DataInsights
Super User
Super User

@robaranieri,

 

Try this solution that utilizes a fields parameter. Each measure needs to be created, since a calculation group doesn't seem to allow sorting on a specific column as you indicated.

 

1. Create the table Topic with each topic and its associated measure names:

 

DataInsights_0-1666278315524.png

 

2. Create a fields parameter with each measure listed in the table above. Uncheck "Add slicer to this page".

 

DataInsights_1-1666278361710.png

 

3. Create a relationship between Topic and TopicParameter. The default is bidirectional, but I changed it to unidirectional (I avoid bidirectional relationships whenever possible).

 

DataInsights_2-1666278408895.png

 

4. Create a matrix and add TopicParameter to the Values field well:

 

DataInsights_3-1666278527846.png

 

5. Create a slicer using Topic[Topic].

 

6. Sort by any matrix column:

 

DataInsights_4-1666278588968.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.