Ger Cas
Ger Cas

Reputation: 2298

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")

Upvotes: 0

Views: 71

Answers (1)

Dan
Dan

Reputation: 10680

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
    )
)

Upvotes: 1

Related Questions