-1

I have a filter Nombre/Montant in the static_table_filter[filter_name] :

enter image description here

If I select Nombre it will get the Montant measure, if I select Montant it will get the Montant measure

SwitchFilter = 
var selected = SELECTEDVALUE(static_table_filter[filter_name])

var Nombre = 'Measure'[Nombres]
var Montant = 'Measure'[Montant]

var result = 
switch(true(),
selected= "Nombre", Nombre,
selected= "Montant",Montant
)
return
result

I am putting the SwitchFilter in a stacked bar chart like below adding a column category :

enter image description here

I want when I select Montant the formatting in the chart will be in euros (adding a symbol €) and when I select Nombre the formatting will be in K like for example 5000 becomes 5K. How can I reach that ?

I am using a live connection to an SSAS tabular cube.

Amira Bedhiafi
  • 8,088
  • 6
  • 24
  • 60
  • Try to add in your measure FORMAT; https://dax.guide/format/ – msta42a Jan 18 '22 at 19:26
  • @msta42a The result is always a string, even when the value is blank. So we the chart won't return any value – Amira Bedhiafi Jan 18 '22 at 20:26
  • You have right. This approach work in table/ card visual but not in chart unfortunately;seems to be limitations in PBI as far as my understanding. You may try to add "custom" legend (card visualization) for some of your selection for example currency; – msta42a Jan 19 '22 at 08:21

1 Answers1

1

I think the easiest way is to create the Nombres and Montant measures (or new measures) with the switch logic, and then just put both measures in the stacked bar chart. Then you can format each measure however you like it.

Nombres = SUM(Data[Nombres]) * IF(SELECTEDVALUE(static_table_filter[filter_name]) <> "Nombre",0,1)
Montant = SUM(Data[Montant]) * IF(SELECTEDVALUE(static_table_filter[filter_name]) <> "Montant",0,1)

Sorting, the legend, and the x-axis labels could be a little tricky, but it looks like you have the legend and the x-axis labels off. To sort, I would just add another measure to the chart and sort on it.

Sort = ([Nombres] + [Montant])/1000000

Montant

Nombre

TheRizza
  • 1,577
  • 1
  • 10
  • 23