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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

calculate subtotals with if statement

hi community,

 

I have an if-statement to calculate 2 measures like this:

Measure =
VAR Selected_Period = MAX(PERIOD1)
VAR Matrix_Period = MAX(PERIOD2)
RETURN
    IF (
        Selected_Period < Matrix_Period,
       SUMX(TABLE1,[AMOUNT1]
       SUMX(TABLE1, [AMOUNT2]

This works fine in a matrix over different periods. But the subtotals do not work

 

 

Any tips?

 

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous 

 

Maybe you can use the IF(), HASONEVALUE() and SUMMARIZE() function to get the correct outcome.

HASONEVALUE function (DAX) - DAX | Microsoft Learn

SUMMARIZE function (DAX) - DAX | Microsoft Learn

 

If the above one can't help you, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

Top Kudoed Authors