Forum Discussion

Ricardo77's avatar
Ricardo77
Helper II
4 years ago
Solved

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)   A...
  • Anonymous's avatar
    Anonymous
    4 years ago

    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