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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
bartw00
Frequent Visitor

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
v-zhengdxu-msft
Community Support
Community Support

Hi @bartw00 

 

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.