Forum Discussion

MarieD's avatar
MarieD
Icon for Helper I rankHelper I
6 years ago

Switch formula doesn't work correctly

Hi all,

 

I'm currently working on a financial report with a template. I want to make a difference in amount in euro's and the percentages.

For both I use a switch formula which is working as expected for the amounts, but the same formula used for the percentages, i only returning values for part of the rows, and not for all the rows in between as shown in table on the left.

 

When not used in the template but directly to the financial descriptions, the actual% is giving correct amounts. But when I want to use it whith the template descriptions, something went wrong..

 

 

This is the formula for the amounts that works fine:

Selected Year Actuals =
Var CurrentItem = SELECTEDVALUE('Template WV'[Omschrijving-normalized])

RETURN
SWITCH ( TRUE(),
CurrentItem = "Omzet", DIVIDE([Omzet],1,0),
CurrentItem = "Bedrijfsresultaat", DIVIDE([Bedrijfsresultaat],1,0),
CurrentItem = "Operationele kosten", DIVIDE([OperationeleKosten],1,0),
CurrentItem = "Brutowinst", DIVIDE([Brutowinst],1,0),
CurrentItem = "Resultaat voor belasting", DIVIDE([Resultaat voor belasting],1,0),
CurrentItem = "Nettoresultaat", DIVIDE([Nettoresultaat],1,0),

CALCULATE( [Actuals] , FILTER( 'Financiele resultaten' , 'Financiele resultaten'[Omschrijving]= CurrentItem ) ) )
 
 
And this is the second formula for the percentages that is NOT working as I want:
Selected Year Actuals % =
Var CurrentItem = SELECTEDVALUE('Template WV'[Omschrijving-normalized])

RETURN
SWITCH ( TRUE(),
CurrentItem = "Omzet", DIVIDE([Omzet%],1,0),
CurrentItem = "Bedrijfsresultaat", DIVIDE([Bedrijfsresultaat%],1,0),
CurrentItem = "Operationele kosten", DIVIDE([OperationeleKosten%],1,0),
CurrentItem = "Brutowinst", DIVIDE([Brutowinst%],1,0),
CurrentItem = "Resultaat voor belasting", DIVIDE([ResultaatVoorBelasting%],1,0),
CurrentItem = "Nettoresultaat", DIVIDE([Nettoresultaat%],1,0),

CALCULATE( [Actuals%] , FILTER( 'Financiele resultaten' , 'Financiele resultaten'[Omschrijving]= CurrentItem ) ) )
 
Both are exactly the same, so I don't know what is wrong? It would be great if somebody can help me!
 
Many thanks,

 

9 Replies