Forum Discussion

apatwal's avatar
apatwal
Helper III
4 years ago
Solved

Help in Creating a calculated Column or Measure

Hi,

 

I am new to Power Bi and need help in creating measure to include status column which includes Decrease if Revenue 2020 > Revenue 2021 else Increase for each combination of customer and product.

 

I have below table

 

Requires below output

Irrespective of date and location, sum the value of Revenue 2021 and Revenue 2020 and then create a column to include Decrease or Increase based on these values.

 

Any help or guidance will be appreciated.

 

  • Hi apatwal ,

     

    You can create a measure with below code:-

    Status =
    IF (
        SUM ( 'Table (3)'[revenue 2021] ) < SUM ( 'Table (3)'[revenue 2020] ),
        "Decrease",
        "Increase"
    )

     

    Output:-

     

    Thanks,

    Samarth

2 Replies

  • Samarth_18's avatar
    Samarth_18
    Community Champion

    Hi apatwal ,

     

    You can create a measure with below code:-

    Status =
    IF (
        SUM ( 'Table (3)'[revenue 2021] ) < SUM ( 'Table (3)'[revenue 2020] ),
        "Decrease",
        "Increase"
    )

     

    Output:-

     

    Thanks,

    Samarth

  • Anonymous's avatar
    Anonymous
    Not applicable

    Please Try This Measure 

    Status = 
    VAR _R2020 = SELECTEDVALUE('Table'[Revenue 2020])
    VAR _R2021 = SELECTEDVALUE('Table'[Revenue 2021])
    VAR RESULT  = SWITCH(TRUE(),_R2020>_R2021,"Decrease","Increase")
    return RESULT