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
appsac1
Helper I
Helper I

If statement error "Dax comparison operators do not support comparing values of type text

I am receiving an error on trying to create an IF statement:

appsac1_0-1656104473300.png

Resoultion Time Status =
IF(
[Granulated] = "OPEN" , "OPEN",
IF(
[Granulated] <=1, "24 hours",
IF(
[Granulated] <=2, "48 hours",
IF(
[Granulated] <=3, "72 hours",
IF(
[Granulated] <=4, "96 hours",
">5 days")))))
 
Any help with this would be of really appreciated.
12 REPLIES 12
v-zhangti
Community Support
Community Support

Hi, @appsac1 

 

You can try the following methods.

Resoultion Time Status = 
IF(
[Granulated] = "OPEN" , "OPEN",
IF(
VALUE([Granulated]) <=1, "24 hours",
IF(
VALUE([Granulated])<=2, "48 hours",
IF(
VALUE([Granulated])<=3, "72 hours",
IF(
VALUE([Granulated]) <=4, "96 hours",
">5 days")))))

vzhangti_0-1656406504733.png

Is this the output you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

The issue is with my Granulated measure not working, because of which the results for Resolution time status shows just as 24 hours and Open.
Below is the measure that I created for Granulated:

 

Shreya08_0-1656432025432.png

I don't have an option to upload my pbix file on the forum, I am sharing the workspace link 
https://app.powerbi.com/groups/me/reports/080c3ce8-6d27-4120-8721-e6824f854b43/ReportSection

Anonymous
Not applicable

I fixed this temporarily by replacing open in the Granulated formulae by 0
Old - Granulated = IF(ISBLANK('April Tickets'[Resolved time].[Date]),FORMAT( "open" , ([Resolved time].[Date] - [Created time].[Date])*1.))

New

Granulated = IF(ISBLANK('April Tickets'[Resolved time].[Date]), 0 , DATEDIFF('April Tickets'[Created time],'April Tickets'[Resolved time],DAY))
 
But I want open and not o to show in my table and I am unable to find a way to have both text and int. The format option isn't working.
ryan_mayu
Super User
Super User

@appsac1 

we can only have one type for one column. So we can't have text which is Open and number which are 1,2,3,4.

 

may be you can try this:

 

Resoultion Time Status =
IF(
[Granulated] = "OPEN" , "OPEN",
IF(
[Granulated] *1<=1 ."24 hours",
IF(
[Granulated] *1<=2"48 hours",
IF(
[Granulated] *1<=3"72 hours",
IF(
[Granulated] *1<=4"96 hours",
">5 days")))))




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Thank you so much it worked, could you explain the logic behind adding [Granulated] *1?

@Anonymous  

did that to transfer text to number and then we can do the comparation.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

I tried adding it to the table visual, but it only gives me two column fields "open" and "24 hours" as below:

 

Shreya08_0-1656370094143.png

 

@Anonymous 

could you pls provide the sample data?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

I am unable to upload the file, but below is the workspace link:
https://app.powerbi.com/groups/me/reports/080c3ce8-6d27-4120-8721-e6824f854b43/ReportSection

@Anonymous 

I can't open the report. you can provide some dummy data or just a part of your real data and paste it in the reply.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Seanan
Solution Supplier
Solution Supplier

Hi @appsac1 

Could you please post the Grandulated measure code.

Anonymous
Not applicable

Sure, below is the measure code

Granulated = IF(ISBLANK('April Tickets'[Resolved time].[Date]),FORMAT( "open" , ([Resolved time].[Date] - [Created time].[Date])*1.))

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.