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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
LLGreen
Regular 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
v-zhouwen-msft
Community Support
Community Support

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

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. @v-zhouwen-msft 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?










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


Proud to be a Super User!









"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]
)

 

 










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


Proud to be a Super User!









"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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.