# Issue with SWITCH TRUE formula

Hi All,

I’m working on a P&L template . The P&L accountnames and numbers are coming from the financial system, but I had to add a few additional categories to them, called ‘DGM categories’. I have attached these in Query Editor and this all seems to be okay.

So for most of the P&L accounts (“Grootboek” in my report) I can use one single measure called “Actual” :

Actual = SUM(GrootboekMutaties[BedragValuta])

For the additional DGM categories I have created a few measure to calculate the values. One of the measures to calculate DGM OEM is this one:

DGM OEM =
ABS
(CALCULATE(
SUM(GrootboekMutaties[BedragValuta]), GrootboekMutaties[GrootboekRekening.1]= “8000”)) -

ABS
(CALCULATE(
SUM(GrootboekMutaties[BedragValuta]) , GrootboekMutaties[GrootboekRekening.1] = “7000”))

This is giving me the result I expected when I add this measure to a Card Visual.

Then i use a Swith true statement, which should decide to return one of the DGM measures, or Actual:

Actuals PL complete =

Var CurrentItem = SELECTEDVALUE(GrootboekRekening[Grootboek])

RETURN

SWITCH ( TRUE(),

CurrentItem = “DGM OEM”, 1,

CurrentItem = “DGM 2USB”, 1,

CurrentItem = “DGM 3TH PARTY”, 1,

CurrentItem = “DGM OTHER”, 1,

CurrentItem = “DGM”, 1,

CurrentItem = “DGM %”, 1,

CurrentItem = “EBITDA”, 1,

[Actual])

Now this is where my problem is. The ''1" should be replaced by the DGM measure, but then it is returning an empty field. As long as I don’t use a measure, but “1” it will give me the number 1, so looks like the SWITCH TRUE formule itselves is working fine, but it is not working in combination with the measures.

Does anyone now what is wrong and how I can solve this?

Many thanks!

Hi @marieke,

You have seven 1’s listed so what does your SWITCH/TRUE actually return?

Best way to trouble shoot is add a Table visual to your canvas with the GrootboekRekening[Grootboek] and your [Actuals PL complete] measure then in context you should get the correct value for each line.
If that’s not the case it’s usually something small like a type-o or missing space in the hard coded text.

I hope this is helpful, if you need further assistance please attach a sample PBIX

2 Likes

Hi @marieke, did the response provided by @Melissa help you solve your query? If not, how far did you get and what kind of help you need further? If yes, kindly mark the thread as solved. Thanks!

Hi @Melissa

I used the 1’s just to check if the SWITCH/TRUE formula itselves was working. And I got the 1’s in the rows where i expected them, so it was working.
But when I replaced the 1’s by the measure I wanted to use, it was not working anymore and returning a blank cell instead of the expected outcome of the measure.

Thanks to this topic Issue /w Switch True
, I have figured out what my problems was. There was an active relationship between the template table and the table with the facts.

Now that I have made some changes to my data-model, this is working fine.

Many thanks!

2 Likes