Forum Discussion
IF and SWITCH is not working
I'm trying to build a measure using IF or SWITCH, but DAX is not allowing me to load the tables:
Thanks a lot
Daniel
The number 1 means first element?
May I use this too?
IF( CONTAINS ( 'Fluxo de caixa', 'Fluxo de caixa'[Tipo], "Entrada" ); SUM('Fluxo de caixa'[Valor]) + SUM('Fluxo de caixa'[Saldo final de caixa]); SUM('Fluxo de caixa'[Valor]) - SUM('Fluxo de caixa'[Saldo final de caixa]) )
- Anonymous8 years ago
The second argument of FIRSTNONBLANK is rarely used. 1 returns a value of "True" and allows the function to work without an expression there. I think the second argument of FIRSTNONBLANK ought to be optional but I didn't write the language.
CONTAINS won't work the way you're expecting. Does the way I wrote it not give you the results you're looking for?
Try this instead:
CALCULATE( SUM('Fluxo de caixa'[Valor]) + SUM('Fluxo de caixa'[Saldo final de caixa]); FILTER( 'Fluxo de caixa'; 'Fluxo de caixa'[Tipo] = "Entrada" ) ) + CALCULATE( SUM('Fluxo de caixa'[Valor]) - SUM('Fluxo de caixa'[Saldo final de caixa]); FILTER( 'Fluxo de caixa'; 'Fluxo de caixa'[Tipo] <> "Entrada" ) )
8 Replies
- AnonymousNot applicable
You can't refer to naked tables or columns in measures, you have to aggregate the data (sum, min, max, firstnonblank, etc.).
- danielsouza
Helper III
I see.
But I would like to work with string:
Saldo final = IF('Fluxo de caixa'[Tipo]="Entrada";SUM('Fluxo de caixa'[Valor])+SUM('Fluxo de caixa'[Saldo final de caixa]);sum('Fluxo de caixa'[Valor])-sum('Fluxo de caixa'[Saldo final de caixa]))
Fluxo de caixa[Tipo] only has text.
How can I aggregate the data?
- AnonymousNot applicable