Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Filter on FIRSTNONBLANK

Hi,

 

I want to calculate something and filter on a string value in a DAX formula.

In my slicer I select some string values and I want to calculate the value of the first string value.

 

But this syntax doesn't work...

 

CALCULATE(Table'[value] ; 'Table'[StringColumn] = FIRSTNONBLANK('Table'[StringColumn];0))

 

 It gives the error: A function 'FIRSTNONBLANK' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

 

How can I fix this?

  • hI Anonymous

     

    Try this

     

    Measure =
    VAR MYVALUE =
        FIRSTNONBLANK ( 'Table'[StringColumn], 0 )
    RETURN
        CALCULATE ( SUM ( 'Table'[value] ), 'Table'[StringColumn] = myvalue )

1 Reply

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Community Champion

    hI Anonymous

     

    Try this

     

    Measure =
    VAR MYVALUE =
        FIRSTNONBLANK ( 'Table'[StringColumn], 0 )
    RETURN
        CALCULATE ( SUM ( 'Table'[value] ), 'Table'[StringColumn] = myvalue )