Forum Discussion

AC4's avatar
AC4
Frequent Visitor
2 years ago
Solved

Different Measure for Row Totals

Hi all,

 

I have a measure that removes filters from an another measure using the all function on two dimensions, account, and account group.

 

The measure is like so.

 

ALL Last Year =
VAR Calc =
IF (
    ISBLANK ( CALCULATE([Selected Measure Total]+[Selected Measure Last Year Total], ALLEXCEPT('Date', 'Date'[Year]) ) ),
    BLANK (),
    CALCULATE (
        [Selected Measure Last Year Total],
        ALL ( 'Account'[Account] ),
        ALL ( 'Account Group'[Account Group] )
    )
)
Return
Calc
 
This works as intended on the level below accounts, sub accounts, and allows me to see if there was any "selected measure total" for last year outside of that account/account group for that sub account. But when adding this measure to a matrix it obviously totals it incorrectly for me (correctly as per the logic) for Accounts and Account Groups. 
 
I would like for the the totals for Accounts and Account groups to be the totals of all the subaccounts nested inside of them.
 
I followed the advice of this thread https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376 to use HASONEFILTER to alter the result if subaccount <> have one filter, but my problem is I cannot get the alternate formula for when it does not have a filter, to work as intended.
 
The most logical to me is 
Return
IF ( HASONEFILTER ( SubAccount[SubAccount] ), Calc, SUMX ( SubAccount, Calc ) )
 
But this multiplies the original incorrect (correct) value by the number of subaccounts in total selected. 
 
I have tried using combinations of keepfilters, summarize, calculatetable etc but can't seem to crack it.
 
Any help would be appreciated, thanks.

1 Reply