Forum Discussion

jaryszek's avatar
jaryszek
Super User
7 months ago
Solved

Calculation group - how to make this working - example model attached.

I am trying to validate a Calculation Group in Power BI, but it does not seem to be applied to visuals. Setup: I created a Calculation Group called Granularity with two calculation items: Daily...
  • MFelix's avatar
    MFelix
    7 months ago

    Hi jaryszek ,

     

    Ths is how calcaulation items work, no matter what calculation you have you will get the value on the calculation item in this case you have the following calculation items:

    Daily = 999
    
    Monthly = 10000000

     

    Being a calculation Group whateve measure you apply this the result will be 999 or 10000000 so let's do this step by step.

     

    No calculation item applied:

     

    In this case the measure returns monthly or  Daily has you can see I have not selecteced any value from the Granularity slicer.

     

    Selecting Monthly Daily Value:

     

     

    When I select the monthly value since this is a measure the value of that measure is overwritten by 999

     

     

    When I select monthly it gets the 10M

     

    Basically you are overwritting the calculation and making it a new calculation.

     

    For the calculations group to work properly you can use the additional syntax:

     

    SELECTEDMEASURE

    ISSELECTEDMEASURE

    SELECTEDMEASUREFORMATSTRING

    SELECTEDMEASURENAME

     

    All of this allow you to tell on top of what the calculation is going to be performed if you just pickup a specific measure on your calculation group that value would always be used with that measure however using the syntax above you can do it for a specific calculation or for all of them.

     

    For example if my code was:

    Daily = IF(ISSELECTEDMEASURE([Date Hierarchy Selection]), SELECTEDMEASURE(), 999)

    For this measure Date Hierachy Selection it will always return the maximum value of the calculation group in this case Monthly:

     

     

    That is the reason why the previous calculation groups I have sent you were:

     

    Monthly = m = SELECTEDMEASURENAME()
    RETURN
    SWITCH(
        TRUE(),
        m = "Total Amortized Cost", [Total Amortized Cost (Monthly)],
        SELECTEDMEASURE()
    )

    In this I check if the measure is "Total Amortized Cost", if it is I return the monthly calculation otherwise I return the value of the measure.