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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MSAYED26
Helper II
Helper II

Dax

CodeName  
PM 750 MGAmeasure120
CD-6"ASXBmeasure240
500-182-30Cmeasure335
CD-12"CPD  
2046SB  
103-137D  
530-123C  
CD-30DCE  
CD-30DCA  
CD-30DCF  
CD-30DCF  
CD-30DCE  
CD-20APXA  
CD-20APXG  
CD-20APXC  
CD-20APXG  
192-630-10C  

I want to write a Dax measure to calculate (measure1 /2) if name =A or B, (measure2 /5) if name =C or D or E,(measure3 /7) if name =F or G 

Thanks,,,,

1 ACCEPTED SOLUTION
ChiragGarg2512
Super User
Super User

@MSAYED26 

1) Create a measure that changes with the selection in the filter. Ex. measure4 = values(name)

 

2.1) create another measure using switch statement. measure5 = switch(measure4, "A", [measure 1]/2, "B", [measure 1]/2, .......).

OR

It can also be done with IF statement.

2.2) It can also be done with IF statement. 

Measure 5 = IF([Measure4] IN{"A", "B"}, [Measure 1] /2, IF([Measure4] IN{"C", "D", "E"}, [measure 2]/5, [measure 3]/7))

 

View solution in original post

3 REPLIES 3
ChiragGarg2512
Super User
Super User

@MSAYED26 

1) Create a measure that changes with the selection in the filter. Ex. measure4 = values(name)

 

2.1) create another measure using switch statement. measure5 = switch(measure4, "A", [measure 1]/2, "B", [measure 1]/2, .......).

OR

It can also be done with IF statement.

2.2) It can also be done with IF statement. 

Measure 5 = IF([Measure4] IN{"A", "B"}, [Measure 1] /2, IF([Measure4] IN{"C", "D", "E"}, [measure 2]/5, [measure 3]/7))

 

I mean measure1/2 it divide measure1  /  2

Divide the measures OR divide measure1 by measure2

Also the previous response has been edited, see if that works.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.