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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
LLGreen
Frequent Visitor

DAX measure needed to calculate grand total of another measure

First off, here is what I'm working with:

sample data.png

 

 

 

 

 

 

 

 

 

 

The Date_EOM field is from an unrelated date table, while the Customer column and the three measures (Revenue_True, Revenue_True_Prev, and Revenue_Full_Churn_Detail) reside in another table. They all do what I need them to, but I can't seem to come up with a measure to get the Grand Total of Revenue_Full_Churn_Detail. I've tried variations using HASONEVALUE and SUMX (with and without using VALUES) and I can't get one that matches the total I get when adding the values in Excel. If it was just the Customer column and then the measures or just the Date_EOM column and the measures the HASONEVALUE would work perfectly. But having the data broken down by Customer and Date_EOM is giving me fits.

 

Can anyone point me toward a measure that will give me an accurate Grand Total of the values from the Revenue_Full_Churn_Detail measure?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi danextian ,thanks for the quick reply, I'll add more.

Hi @LLGreen ,

Regarding your question, are you trying to show the sum here?

vzhouwenmsft_0-1730872528654.png

Try this

MEASURE =
VAR _isTotalRow =
    SELECTEDVALUE ( 'Table'[Customer] )
VAR _table =
    SUMMARIZECOLUMNS (
        'Table'[Customer],
        'DateTable'[Date_EOM],
        "Result",
            IF (
                AND ( [Revenue_True] = 0, [Revenue_True_Prev] <> 0 ),
                [Revenue_True] - [Revenue_True_Prev],
                0
            )
    )
RETURN
    IF (
        ISBLANK ( _isTotalRow ),
        SUMX ( _table, [Result] ),
        IF (
            AND ( [Revenue_True] = 0, [Revenue_True_Prev] <> 0 ),
            [Revenue_True] - [Revenue_True_Prev],
            0
        )
    )

 

Best Regards,
Wenbin Zhou

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi danextian ,thanks for the quick reply, I'll add more.

Hi @LLGreen ,

Regarding your question, are you trying to show the sum here?

vzhouwenmsft_0-1730872528654.png

Try this

MEASURE =
VAR _isTotalRow =
    SELECTEDVALUE ( 'Table'[Customer] )
VAR _table =
    SUMMARIZECOLUMNS (
        'Table'[Customer],
        'DateTable'[Date_EOM],
        "Result",
            IF (
                AND ( [Revenue_True] = 0, [Revenue_True_Prev] <> 0 ),
                [Revenue_True] - [Revenue_True_Prev],
                0
            )
    )
RETURN
    IF (
        ISBLANK ( _isTotalRow ),
        SUMX ( _table, [Result] ),
        IF (
            AND ( [Revenue_True] = 0, [Revenue_True_Prev] <> 0 ),
            [Revenue_True] - [Revenue_True_Prev],
            0
        )
    )

 

Best Regards,
Wenbin Zhou

 

Thank you SO much, both of you, for getting me out of a tight spot. @Anonymous I tried your solution first (since it was the first I saw) and it works perfectly. I will say good things about both you and @danextian for the rest of my days.

danextian
Super User
Super User

Hi @LLGreen 

 

What formulas have you tried to get the total?

What is the formula used in Revenue_Full_Churn_Detail?





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Here's the measure for Revenue_Full_Churn_Detail: 

Revenue_Full_Churn_Detail = IF(AND([Revenue_True]=0,[Revenue_True_Prev]<>0),[Revenue_True]-[Revenue_True_Prev],0)

 

As for what I've tried, I've tried just about everything I was able to find online. I've tried things such as 

IF(HASONEVALUE(<Customer>),[Revenue_Full_Churn_Detail],SUMX(<table>,[Revenue_Full_Churn_Detail])

I've tried a similar measure using Date_EOM instead of Customer, but was never able to do the equivalent of

AND(HASONEVALUE(<Customer>),HASONEVALUE(Date_EOM))

I've even tried things along the lines of 

SUMX(UNION(VALUES('Table1'[Customer]),VALUES('Table2'[Date_EOM])),[Revenue_Full_Churn_Detail])

Each one has given a different answer, but none have been correct. I'm not sure what else to look at.

 

 

hi @LLGreen,

Your Revenue_Full_Churn_Detail formula will not work because at the total level [Revenue_True] is not equal to 0 and at the date level, both can be blank or not blank but not zero (that's how your screenshot appears to me). Your SUMX formulas will not work either because the evaluation is by customer and not by date. If you want SUMX  to evaluate your churn logic by date and customer, you must include them both in the table expression which of course cannot be done with VALUES as it accepts a single column only.

 

SUMX (
    ADDCOLUMNS (
        SUMMARIZE ( 'table', 'dates'[date_EOM], customer[customer] ),
        "@churn",
            IF (
                ISBLANK ( [Revenue_True] ) && NOT ( ISBLANK ( [Revenue_True_Prev] ) ),
                [Revenue_True] - [Revenue_True_Prev]
            )
    ),
    [@churn]
)

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.