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