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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
salil7
Regular Visitor

Incorrect Matrix subtotals for the measure calculated based on user defined selection in the slicer

Hello experts,

I have a peculiar issue which I am not able to resolve. I have the underlying data organized in the following format

 

ScenarioProductMonthQuantity
1XJan100
1XFeb800
1YJan750
1YFeb200
2XJan300
2XFeb450
2YJan550
2YFeb500

 

I have a slicer to select the scenarios and have created a measure to calculate the difference in quantity based on any two selected scenarios. Eg. If the user selects Scenario 1 and 2 from the slicer, he should see (Scenario 2-Scenario 1)

ProductJanFeb
X200-350
Y-200300

 

Measure definition:

DeltaMeasure =
VAR Top1N =
VALUE (
CALCULATE (
CONCATENATEX (
TOPN ( 1, VALUES ( 'MST_SCENARIO'[Index] ) ),
'MST_SCENARIO'[Index],
", "
)
)
)
VAR Top2N =
VALUE (
CALCULATE (
CONCATENATEX (
TOPN ( 1, VALUES ( 'MST_SCENARIO'[Index] ), 'MST_SCENARIO'[Index], DESC ),
'MST_SCENARIO'[Index],
", "
)
)
)
VAR FirstSelectedValue =
CALCULATE ( SUMX(ScenarioComparisonData,ScenarioComparisonData[Measure]),MST_SCENARIO[Index]=Top1N)
VAR SecondSelectedValue =
CALCULATE ( SUMX(ScenarioComparisonData,ScenarioComparisonData[Measure]),MST_SCENARIO[Index]=Top2N)
RETURN
SecondSelectedValue - FirstSelectedValue
 
I want to visualize this in a matrix visual.
 
Everything works as expected when I put Product and Month in the rows and DeltaMeasure in the values. However, I see random subtotals when I put Month in columns (Everything else remains the same).
 
I can provide further information if required. Any help in this regard will be highly appreciated.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @salil7 ,

According to your description and screenshots, it seems the data display in the bottom visual is not correct every row.... Could you please provide the related setting of bottom visual in Fields pane? And please provide some sample data in table ScenarioComparisonData and MST_SCENARIO if it is convinent in order to make troubleshooting. Thank you.

Best Regards

View solution in original post

4 REPLIES 4
salil7
Regular Visitor

Thanks, @amitchandak  for your response. Is there a way to extend this logic to multiple columns? I have attached the screenshot of my Power BI desktop. In the top visual, you will see that I have Family, Origin, Destination, Mode and Product defined in the Rows. Period in the column and DeltaMeasure in the values. In the bottom visual, I have exactly the same row hierarchy (+Scenario), Period in columns and Measure in the values.

I expect the difference between the row subtotals of the bottom visual to match the values in the top visual period by period. As you will observe, the difference in the row subtotals for the two rows in the bottom visual (15,185,274-15,071,377) exactly matches the grand total in the top visual 113,897. However, if you look at the values in individual periods: Period 202007 as an example - I expect the top visual to populate 836,791 - 874,763 = -37,792 as the value. But what I see is -16,032.

Any pointers on how can I achieve this? Many thanks for your help.

PowerBI Issue.JPG

Anonymous
Not applicable

Hi @salil7 ,

According to your description and screenshots, it seems the data display in the bottom visual is not correct every row.... Could you please provide the related setting of bottom visual in Fields pane? And please provide some sample data in table ScenarioComparisonData and MST_SCENARIO if it is convinent in order to make troubleshooting. Thank you.

Best Regards

Hi @Anonymous ,

You are right. I realized that there was a visual level filter for the top visual where I had a put a condition that DeltaMeasure should not be equal to zero. It started showing me the right numbers when I removed that filter. Thank you for the pointers! 

amitchandak
Super User
Super User

@salil7 , Change return like 

return

sumx(values(ScenarioComparisonData[product]), SecondSelectedValue - FirstSelectedValue)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

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.

Top Solution Authors
Top Kudoed Authors