Forum Discussion

ashamsuzzoha's avatar
ashamsuzzoha
Icon for Advocate II rankAdvocate II
5 years ago
Solved

Percentage change from a fixed point

I have the following data. [No. of Incidents per feeder_2] is a calculated measure, and TableName[Years Since Last Trim] is a dim table column. I want another measure that calculates the percentage change from [Years Since Last Trim] = 3

 

Years Since Last TrimNo. of Incidents per feeder_2Expected Value
32.676861702 
43.13374233117%
53.18098510919%
63.4631979729%
73.79132791342%
83.73989455240%
94.01049868850%
104.13930348355%

 

How do you do this in DAX? Thanks

  • Never mind, I figured out. I thought it was going to be more complicated than using calculate().

     

    #_Pct change since Yr 3 = 
    
    DIVIDE(
        [No. of Incidents per feeder_2], 
        CALCULATE([No. of Incidents per feeder_2], 'Years Since Last Exposure'[Years Since Last Trim] = 3)
    ) - 1
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi ashamsuzzoha ,

    You can create a measure as below:

    #_Pct change since Yr 3 = 
    VAR _curfeeder =
        MAX ( 'Years Since Last Exposure'[No. of Incidents per feeder_2] )
    VAR _3feeder =
        CALCULATE (
            MAX ( 'Years Since Last Exposure'[No. of Incidents per feeder_2] ),
            FILTER (
                ALLSELECTED ( 'Years Since Last Exposure' ),
                'Years Since Last Exposure'[Years Since Last Trim] = 3
            )
        )
    RETURN
        DIVIDE ( _curfeeder, _3feeder ) - 1​

    It seems you have already resolve it by yourself, the above one is for reference only. Could you please mark this thread as Answered? Thank you.

    Best Regards

    Rena

     

     

     

2 Replies

  • Never mind, I figured out. I thought it was going to be more complicated than using calculate().

     

    #_Pct change since Yr 3 = 
    
    DIVIDE(
        [No. of Incidents per feeder_2], 
        CALCULATE([No. of Incidents per feeder_2], 'Years Since Last Exposure'[Years Since Last Trim] = 3)
    ) - 1
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi ashamsuzzoha ,

      You can create a measure as below:

      #_Pct change since Yr 3 = 
      VAR _curfeeder =
          MAX ( 'Years Since Last Exposure'[No. of Incidents per feeder_2] )
      VAR _3feeder =
          CALCULATE (
              MAX ( 'Years Since Last Exposure'[No. of Incidents per feeder_2] ),
              FILTER (
                  ALLSELECTED ( 'Years Since Last Exposure' ),
                  'Years Since Last Exposure'[Years Since Last Trim] = 3
              )
          )
      RETURN
          DIVIDE ( _curfeeder, _3feeder ) - 1​

      It seems you have already resolve it by yourself, the above one is for reference only. Could you please mark this thread as Answered? Thank you.

      Best Regards

      Rena