Search code examples
powerbidaxpowerpivot

How to show rows when column match criteria?


How can I define a measure to set a condition to show values of apples when column = fruits contains the string apple?

I've tried this but I only see query batch complete with errors.

MEASURE Table1[apples] = IF(SEARCH("apple",'Table1'[Fruits]),"Yes","No")

Solution

  • Assuming you want to return a sum of the column 'Table1'[Value] for those rows where the 'Table1'[Fruits]-column contains the string "apple", you should use:

    MEASURE Table1[apples] = 
    CALCULATE ( 
        SUM ( 'Table1'[Value] ),
        KEEPFILTERS(
            SEARCH ( "apple", 'Table1'[Fruits], 1, 0 ) <> 0
        )
    )