Forum Discussion

mizaskun's avatar
mizaskun
Icon for Helper II rankHelper II
5 years ago
Solved

Modify measures depending on filters

Good morning,

 

I have a very simple model:

 

UserTypeAmount
AZ100
AZ200
AY50

 

I created the following measure:

TotalByUser = calculate( sum(Table[Amount]), allexcept(Table, Table[User]))

 

I created a very simple report:

UserTypeAmountTotalByUser
AZ300350
AY50350

 

And when I filter the report by Type = Z, y get the following:

UserTypeAmountTotalByUser
AZ300350

 

What I would need is to filter the measure the same way the report is being filtered. The result should be:

UserTypeAmountTotalByUser
AZ300300

 

And if I unresume the Amount field, the result should look like this applying the filter:

UserTypeAmountTotalByUser
AZ100300
AZ200

300

 

And like this if I do not apply it:

UserTypeAmountTotalByUser
AZ100350
AZ200350
AY50350

 

Is it possible to achieve this? Does anybody know how to do it? 

 

Thank you so much!

  • TotalByUser =
    CALCULATE(
        SUM( Table[Amount] ),
        VALUES( Table[User] ),
        ALLSELECTED( 'Table' )
    )

    It might be that the above does what you want...

5 Replies

  • mizaskun , Try a measure like

     

    sumx(values(Table[User]) ,if(isfiltered(Table[Type]) , calculate(sum(Table[Amount])), calculate( sum(Table[Amount]), allexcept(Table, Table[User]))))

    • mizaskun's avatar
      mizaskun
      Icon for Helper II rankHelper II

      Good morning,

       

      Thank you for your answer! The model actually have much more fields through which can be filtered. The table I explained was a simplification to make it easier to understand what I need. There should be a way to achieve that behavour. 

       

      Thank you so much! 

      • daxer-almighty's avatar
        daxer-almighty
        Icon for Solution Sage rankSolution Sage
        TotalByUser =
        CALCULATE(
            SUM( Table[Amount] ),
            VALUES( Table[User] ),
            ALLSELECTED( 'Table' )
        )

        It might be that the above does what you want...