cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gauravnarchal
Post Partisan
Post Partisan

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 II
Helper II

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 accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

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 accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

View solution in original post

pra137
Helper II
Helper II

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

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!