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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
danextian
Super User
Super User

SUMX of SUMMARIZE not showing correct total

Hello,

 

I'm stuck at this as the result is not what I have expected. Basically my goal here is to dynamically move certain balance sheet accounts between assets and liabilities group depending on the current balance. If an account has two balance sheet groups and the balance is positive then it is an asset else a liability. Once moved, I will then get the total of each group. On the account level, the formula is showing correctly but the balance sheet group total is overstated. 

Totals_ = 
VAR __groupcount =
    CALCULATE (
        DISTINCTCOUNT ( Accounts[Balance Sheet Group] ),
        ALLEXCEPT ( Accounts, Accounts[Balance Sheet Account Name] )
    )
RETURN
    SUMX (
        SUMMARIZE (
            Accounts,
            Accounts[Balance Sheet Account Name],
            Accounts[Balance Sheet Group],
            "Balance", SWITCH (
                TRUE (),
                Accounts[Balance Sheet Group] = BLANK() || Accounts[Balance Sheet Group] = "",  BLANK(),
                [Totals by Balance Sheet Account] > 0
                    && __groupcount > 1
                    && Accounts[Balance Sheet Group] = "Assets", [Totals by Balance Sheet Account],
                [Totals by Balance Sheet Account] < 0
                    && __groupcount > 1
                    && Accounts[Balance Sheet Group] = "Assets", BLANK (),
                [Totals by Balance Sheet Account] < 0
                    && __groupcount > 1
                    && Accounts[Balance Sheet Group] = "Liabilities", [Totals by Balance Sheet Account],
                [Totals by Balance Sheet Account] > 0
                    && __groupcount > 1
                    && Accounts[Balance Sheet Group] = "Liabilities", BLANK (),
                Accounts[Balance Sheet Group] = "Equity", [Totals (old)],
                [Totals (old)]
            )
        ),
        [Balance]
    )

 
In the below table, the total should be 883K for July but the total is showing 1.242M which is way off. Help would be much appreciated.
2019-11-04 15_30_56-Window.png










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.
1 ACCEPTED SOLUTION

So I ended up splitting those accounts that move between assets and liabilities by creating two variables. This is the updated formula:

Totals = 
VAR __ONE_GROUP =
    SUMX (
        ADDCOLUMNS (
            FILTER (
                SUMMARIZE (
                    Accounts,
                    Accounts[Balance Sheet Group],
                    Accounts[Balance Sheet Account Name]
                ),
                [Group Count by Balance Sheet Account Name] = 1
            ),
            "Balance", [Totals by Balance Sheet Account]
        ),
        [Balance]
    )
VAR __TWO_GROUPS =
    SUMX (
        ADDCOLUMNS (
            FILTER (
                SUMMARIZE (
                    Accounts,
                    Accounts[Balance Sheet Group],
                    Accounts[Balance Sheet Account Name]
                ),
                [Group Count by Balance Sheet Account Name] > 1
            ),
            "Balance", SWITCH (
                TRUE (),
                [Totals by Balance Sheet Account] > 0
                    && Accounts[Balance Sheet Group] = "Assets", [Totals by Balance Sheet Account],
                [Totals by Balance Sheet Account] < 0
                    && Accounts[Balance Sheet Group] = "Assets", BLANK (),
                [Totals by Balance Sheet Account] > 0
                    && Accounts[Balance Sheet Group] = "Liabilities", BLANK (),
                [Totals by Balance Sheet Account] < 0
                    && Accounts[Balance Sheet Group] = "Liabilities", [Totals by Balance Sheet Account],
                BLANK ()
            )
        ),
        [Balance]
    )
RETURN
    __TWO_GROUPS + __ONE_GROUP

 Sometimes DAX can be very tricky. 










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.

View solution in original post

2 REPLIES 2
danextian
Super User
Super User

After checking, the formula appears to be ignoring the negative values when doing a sumx.










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.

So I ended up splitting those accounts that move between assets and liabilities by creating two variables. This is the updated formula:

Totals = 
VAR __ONE_GROUP =
    SUMX (
        ADDCOLUMNS (
            FILTER (
                SUMMARIZE (
                    Accounts,
                    Accounts[Balance Sheet Group],
                    Accounts[Balance Sheet Account Name]
                ),
                [Group Count by Balance Sheet Account Name] = 1
            ),
            "Balance", [Totals by Balance Sheet Account]
        ),
        [Balance]
    )
VAR __TWO_GROUPS =
    SUMX (
        ADDCOLUMNS (
            FILTER (
                SUMMARIZE (
                    Accounts,
                    Accounts[Balance Sheet Group],
                    Accounts[Balance Sheet Account Name]
                ),
                [Group Count by Balance Sheet Account Name] > 1
            ),
            "Balance", SWITCH (
                TRUE (),
                [Totals by Balance Sheet Account] > 0
                    && Accounts[Balance Sheet Group] = "Assets", [Totals by Balance Sheet Account],
                [Totals by Balance Sheet Account] < 0
                    && Accounts[Balance Sheet Group] = "Assets", BLANK (),
                [Totals by Balance Sheet Account] > 0
                    && Accounts[Balance Sheet Group] = "Liabilities", BLANK (),
                [Totals by Balance Sheet Account] < 0
                    && Accounts[Balance Sheet Group] = "Liabilities", [Totals by Balance Sheet Account],
                BLANK ()
            )
        ),
        [Balance]
    )
RETURN
    __TWO_GROUPS + __ONE_GROUP

 Sometimes DAX can be very tricky. 










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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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