mardi 18 février 2020

PowerBI - create measure - nested IF in returned function

I have a table like this: enter image description here

I would like to have varied results based on different criteria: total_number = VAR category1 = FILTER(ALL('table'[city]), 'table'[city]="new york" || 'table'[city]="atlanta" || 'table' [city]="LA") VAR category2 = FILTER(ALL('table'[city], 'table'[fruit]), 'table'[city]="phenix" || 'table'[fruit] = "apple") VAR Category3 = FILTER(ALL('table'[city], 'table'[fruit]), 'table'[city]="phenix" || 'table'[fruit] = "pear") RETURN CALCULATE ( IF(category1, SUM('table'[number])), IF(category2, (SUM('table'[number])+'change to apple number'[change to apple number])), IF(category3, (SUM('table'[number])+'change to pear number'[change to pear number]))) // the "change" is a parameter

I get this error message: A function 'SUM' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

Can anyone help diagnose this problem? thanks so much!

Aucun commentaire:

Enregistrer un commentaire