Forum Discussion

kulpushu's avatar
kulpushu
Frequent Visitor
2 years ago
Solved

Calculate Difference between Rows for a given Measure

Hi all, I want to calculate the relative value of the ATB by PDP visits between the control (off) and the variance (on) as listed below. The experiments are selected by a drop down selection and unf...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi kulpushu ,

    The Table data is shown below:

    Please follow these steps:
    1. Use the following DAX expression to create a column

    Column = LEFT([Experiment Name],6)

    2.Use the following DAX expression to create a measure

    Off = 
    VAR _a = SELECTEDVALUE('Table'[Column])
    VAR _b = _a & " Off"
    
    RETURN CALCULATE(DIVIDE(SUM('Table'[ATB Visits]),SUM('Table'[PDP vistis]),0),'Table'[Experiment Name] = _b)

    3.Use the following DAX expression to create a measure

    On = 
    VAR _a = SELECTEDVALUE('Table'[Column])
    VAR _b = _a & " On"
    
    RETURN CALCULATE(DIVIDE(SUM('Table'[ATB Visits]),SUM('Table'[PDP vistis]),0),'Table'[Experiment Name] = _b)

     4.Final output

     

    Best Regards,
    Wenbin Zhou
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.