Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Ricardo77
Helper II
Helper II

Simple IF over a string returning wrong errors on a table, what's happening?

Hello, i want to create a simple flag like this:

 

IF (TRIM(SELECTEDVALUE(X[xxx])) <> BLANK() && TRIM(SELECTEDVALUE(X[xxx])) <> "" && TRIM(SELECTEDVALUE(X[xxx])) <> "N/A (abc)",1 , 0)

 


As you can see, IF is not optimized, because i'm trying to see what's happening. I've removed the variables, added trim, and even considered ""

On a report page with some visuals, this IF "column" is returning wrong values, like :

img0.png




















But if i copy this same table to a new page, it works:
img1.PNG

So, what's happening? Could it be any problem with my model?

Regards

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @Ricardo77,

Did you work with the calculated column? If that is the case, they don't respond with the filter and slicers effect so the selectedvalue function may not work properly. (calculate column and filter are work on different data levels, you can use child level to affect its parent)

SELECTEDVALUE function - DAX | Microsoft Docs

I'd like to suggest you direct use the Table[Column Name] to invoke the current row content and compare it with the if statement conditions:

Flag =
IF ( TRIM ( X[xxx] ) IN { BLANK (), "", "N/A (abc)" }, 0, 1 )

Notice: the data level of power bi.

Database(external) -> query table(query, custom function, query parameters) -> data model table(table, calculate column/table) -> data view with virtual tables(measure, visual, filter, slicer)

Regards,

Xiaoxin Sheng

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

HI @Ricardo77,

Did you work with the calculated column? If that is the case, they don't respond with the filter and slicers effect so the selectedvalue function may not work properly. (calculate column and filter are work on different data levels, you can use child level to affect its parent)

SELECTEDVALUE function - DAX | Microsoft Docs

I'd like to suggest you direct use the Table[Column Name] to invoke the current row content and compare it with the if statement conditions:

Flag =
IF ( TRIM ( X[xxx] ) IN { BLANK (), "", "N/A (abc)" }, 0, 1 )

Notice: the data level of power bi.

Database(external) -> query table(query, custom function, query parameters) -> data model table(table, calculate column/table) -> data view with virtual tables(measure, visual, filter, slicer)

Regards,

Xiaoxin Sheng

Ricardo77
Helper II
Helper II

Hello @amitchandak  , thanks for the tip, again it fails on the report page with other visuals, and it's ok in the empty one.
I've found meanwhile that it is something related to the date table, and i believe it should be related to bad dimensional modelling - but open to other ideas 🙂

amitchandak
Super User
Super User

@Ricardo77 , hope there is no filter, drill through the filter, slicer filter etc

 

Also, try like

 

IF ( not isblank(TRIM(SELECTEDVALUE(X[xxx]))) && TRIM(SELECTEDVALUE(X[xxx])) <> "" && TRIM(SELECTEDVALUE(X[xxx])) <> "N/A (abc)",1 , 0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.