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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
gauravnarchal
Post Prodigy
Post Prodigy

Measure in If Statement and Return

Hello – How can I create a measure to show

 

If Product code = 10 return 30 or

If Product code = 12 return 50 or

If Product code = 13 return 70

 

Tabel Name = Sale

 

NameBranchProduct Code(Measure) Add column and show the value in each row
ABC IntlNYC1030
ZZZ LogisticsLON1030
ABC IntlCAI1250
ZZZ LogisticsMEL1250
ABC IntlDEL1250
ABC IntlSHA1370
ABC IntlNYC1370
ZZZ LogisticsNYC1370
2 ACCEPTED SOLUTIONS
pra137
Helper III
Helper III

hi @gauravnarchal 
you can use this measure you will get result

Measure =
var a=SUM(sale[Product Code])
var b=IF(a=10,30,IF(a=12,50,IF(a=13,70)))
Return
b
 
 

View solution in original post

Jihwan_Kim
Super User
Super User

Hi, @gauravnarchal 

Please check the below. The formula is for creating a new column.

 

Picture1.png

 

New Column =
SWITCH ( Sale[Product Code], 10, 30, 12, 50, 13, 70 )

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @gauravnarchal 

Please check the below. The formula is for creating a new column.

 

Picture1.png

 

New Column =
SWITCH ( Sale[Product Code], 10, 30, 12, 50, 13, 70 )

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


pra137
Helper III
Helper III

hi @gauravnarchal 
you can use this measure you will get result

Measure =
var a=SUM(sale[Product Code])
var b=IF(a=10,30,IF(a=12,50,IF(a=13,70)))
Return
b
 
 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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