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
Oros
Post Partisan
Post Partisan

If, else

Hello,

 

I have this 1 table that I would like to create an IF, ELSE column (or a measure) to replace the REGULAR PRICE

 

ITEMREGULAR PRICEDISCOUNTED
BANANA$5 
APPLE$10 
MANGO$20 

 

If discounted=YES, then the price column becomes $1.  If discounted=NO, then regular price.

 

Thanks.

 

1 ACCEPTED SOLUTION
vojtechsima
Memorable Member
Memorable Member

Hi, @Oros 
as Column 

IF ( 'Table'[ISDISCOUNTED] = "YES", 1, 'Table'[REGULAR])

View solution in original post

5 REPLIES 5
Oros
Post Partisan
Post Partisan

Hello @vojtechsima ,

 

Thanks for the prompt reply.  I get an error message.  (DAX comparison operations do not support comparing values of type True?False with values of type Text.)

Oros_0-1653405560995.png

 

Hi, @Oros ,
Make sure your columns are in proper data types, when comparing string ("YES", "NO") the column has to be a text, if numeric values (1,2) it has to be Numeric. PLease check that and try running itagain

Hello @vojtechsima ,

 

I change it to text but got another error:

 

"Expressions that yield variant data-type cannot be used to define calculated columns."

 

Any idea?

 

Thanks.

Shishir22
Solution Sage
Solution Sage

Hello @Oros , 

 

Add a calculated column-

NewColumn = IF(Data[DISCOUNTED]="YES",1,Data[REGULAR PRICE])

 

Shishir22_0-1653404834370.png

 

Please mark it as answer if it resolves your issue. Kudos are also appreciated.

 

 

Cheers,
Shishir
vojtechsima
Memorable Member
Memorable Member

Hi, @Oros 
as Column 

IF ( 'Table'[ISDISCOUNTED] = "YES", 1, 'Table'[REGULAR])

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.