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
irnm8dn
Post Prodigy
Post Prodigy

Numbers to Text with IF Statement

I am currently using a calculation to determine % of Inventory Remaining.

 

I would like to use an "IF" Statement to convert this calculation to "Plain Text" -

i.e. 100% = "SOLD OUT"

 

The challenge I am having is that If statements don't allow you to convert numbers to text:

 

DAX comparison operations do not support comparing values of type Number with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.

 

Any thoughts how I can convert the calc and translate as text?

1 ACCEPTED SOLUTION
kevcurtis
Advocate I
Advocate I

Have you tried using SWITCH in a new column or a measure?

 

[Measure] = your calculation

 

%toText = SWITCH([Measure], 1, "Sold Out", "")

 

%toTextNested = 
SWITCH([Measure],1,"In stock",
(SWITCH([Measure],0,"Sold out",
(SWITCH([Measure],.5,"Low","")))))

View solution in original post

4 REPLIES 4
kevcurtis
Advocate I
Advocate I

Have you tried using SWITCH in a new column or a measure?

 

[Measure] = your calculation

 

%toText = SWITCH([Measure], 1, "Sold Out", "")

 

%toTextNested = 
SWITCH([Measure],1,"In stock",
(SWITCH([Measure],0,"Sold out",
(SWITCH([Measure],.5,"Low","")))))
McCow
Resolver III
Resolver III

Hi @irnm8dn

a possible proposal:
1) convert Num (Percent) column to Text
2) use SEARCH (or FOUND) function in if- statement

 

comparing text-to-text should be ok

 

Best regs

@McCow

 

I cannot convert the percent to text, it is a calc - so that options is disabled.

 

Any other thoughts?

@irnm8dn

can you create a second column as "text description" of the first, numeric column? 

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.