Forum Discussion

Khurram_Ahmed's avatar
Khurram_Ahmed
Frequent Visitor
3 years ago

Using a column as an expression in a measure.

Hi, I have a table (live connected so can't create columns and tables), for the sake of explanation my table is like this:

 

 A                                     B

abc                                date1

abs                                date2

acs                              <blank>

asd                              <blank>

 

I want to add another column (C) to this table based on whether B is blank or not. So it should look like this:

 

 A                                     B                                     C

abc                                date1                              True

abs                                date2                              True

acs                              <blank>                            False

acb                              <blank>                           False

 

 

I tried using the if statement but can't use a column as an expression. I am new to DAX so any help is appreciated.

3 Replies

  • You could create a measure like

    C = NOT( ISBLANK( SELECTEDVALUE('Table'[B]) ) )

    The key is that you cannot use just a column reference in a measure, as it does not know which row you are talking about. You need to use an aggregation function like MIN, MAX etc, or use SELECTEDVALUE to get the value from the current filter context.

    • Khurram_Ahmed's avatar
      Khurram_Ahmed
      Frequent Visitor

      It is not producing the intended result, many rows with dates are also showing false flag.

      • johnt75's avatar
        johnt75
        Super User

        Presumably you are using column A on the visual with the measure. Does column A contain unique values or does it have duplicates? If it has duplicates then you will need to use a different column, or combination of columns, which can uniquely identify a row in the base table.