Forum Discussion

JR503's avatar
JR503
New Member
2 years ago
Solved

Evaluating 3 Columns with three Possible Outcomes

Hello ! I have 2 different columns, Period 1, Period 2. Need a simple function to evaluate and return 3 possible answers:

1. If Period 1 > Period 2 return 1

2. If Period 1 = Period 2 return 0

3. If Period 1 < Period 2 return 2

 

What function do I need to use to do this 3 way evaluation?

 

Was looking at Switch but how do I place the Syntax? 

If statement I believe won't work because it returns only 2 possibilities.

Any other function I need to take a look at?

 

Any thoughts Community? Much apprexiate the help im advance...

 

  • pls try this

     

    MEASURE = 
    VAR _t1 = MAX('your table'[Period 1]
    
    VAR _t2 = MAX('your table'[Period 2]
    RETURN
    SWITCH(
     TRUE(),
         _t1 > _t2 ,1,
         _t1 =_t2 ,0,
         _t1 < _t2 ,2
    )
    
    -------or ----
    
     COLUMN = 
    VAR _t1 = 'your table'[Period 1]
    
    VAR _t2 = 'your table'[Period 2]
    RETURN
    SWITCH(
     TRUE(),     
         _t1 > _t2 ,1,
         _t1 =_t2 ,0,
         _t1 < _t2 ,2
    )

     

    • Ahmedx... you Rock !  I am just starting to play with Power Bi...and this might have been a pretty easy question for you. Learned something more today. Appreciate it very much! Both work. Thank you very much !

2 Replies

  • pls try this

     

    MEASURE = 
    VAR _t1 = MAX('your table'[Period 1]
    
    VAR _t2 = MAX('your table'[Period 2]
    RETURN
    SWITCH(
     TRUE(),
         _t1 > _t2 ,1,
         _t1 =_t2 ,0,
         _t1 < _t2 ,2
    )
    
    -------or ----
    
     COLUMN = 
    VAR _t1 = 'your table'[Period 1]
    
    VAR _t2 = 'your table'[Period 2]
    RETURN
    SWITCH(
     TRUE(),     
         _t1 > _t2 ,1,
         _t1 =_t2 ,0,
         _t1 < _t2 ,2
    )

     

    • JR503's avatar
      JR503
      New Member
      • Ahmedx... you Rock !  I am just starting to play with Power Bi...and this might have been a pretty easy question for you. Learned something more today. Appreciate it very much! Both work. Thank you very much !