Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
gfaccenda
Partner - Contributor
Partner - Contributor

Problem with If statement in a table dimension

Hi everyone, i'm trying to add a column that checks whether the values of the two columns before are the same or not, and returns a tick or a warning symbol, the expression in the column is the following:

=if([Field1]=[Field2], '✔', if(Upper(trim([Field1]))=Upper(trim([Field2)), '⚠', '✖'))

The problem is that it doesn't work when both columns are null on that row and it returns a null value, while i would like to return a "✖". I attach a screenshot of the 3 columns:

 

2023-02-22_15h34_25.png

 

What is strange to me is that the same column has the exact same expression for the color of the text (just switching the symbols with color codes) and that seems to work fine. Moreover when the column is created as a measure and not as a dimension the problem disappears, but i need to be able to select those symbols.
Have you got any idea on how to solve this problem?

Labels (5)
1 Solution

Accepted Solutions
Or
MVP
MVP

My image is from a table, and it appears to be working. Perhaps in your scenario, the table row has no matching rows for whichever table Field1 and Field2 are from? I didn't test that but fields/values that are outright missing can sometimes cause behavior that is not the same as "regular" nulls.

View solution in original post

5 Replies
Or
MVP
MVP

I wasn't able to replicate what you're describing. This seems to work fine with a basic inline load, regardless of whether or not I use the A dimension in my table.

Or_0-1677077901654.png

Or_1-1677077987171.png

 

 

gfaccenda
Partner - Contributor
Partner - Contributor
Author

Yes,  i cannot understand why in that table it is not working

Or
MVP
MVP

My image is from a table, and it appears to be working. Perhaps in your scenario, the table row has no matching rows for whichever table Field1 and Field2 are from? I didn't test that but fields/values that are outright missing can sometimes cause behavior that is not the same as "regular" nulls.

AR_Gonza_2107
Contributor II
Contributor II

HI ! 

Had you tried adding a condition to your 'if' statement with the isnull() function? 

Btw, if those columns comes from a same table in the data model, you could try creating that sort of flag in the script instead.

 

gfaccenda
Partner - Contributor
Partner - Contributor
Author

Thanks @Or,  the problem seemed to be that data weren't coming from the same table and rows werent'matching.