Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
JR503
New Member

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...

 

2 ACCEPTED SOLUTIONS
Ahmedx
Super User
Super User

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
)

 

View solution in original post

  • 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 !

View solution in original post

2 REPLIES 2
Ahmedx
Super User
Super User

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 !

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.