Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello everyone!
I would like to learn how to use the Switch function, from a logical point of view it seems to me to be easy but obviously I didn't understand something.
I'll try to compose the tipical case
LUT_ANA
I create in PBI a table with 1 column having N rows
Attribute |
Quantity |
Value |
Cost |
DATA_TAB
I then have a data table as follows
Art.Code | Quantity | Value | Cost |
A | 23312 | 12312312 | 1231234 |
B | 123 | 13134 | 41412 |
C | 21 | 56 | 21 |
... | ... | ... | ... |
My goal is to create a selector that allows me in a Chart, for example, to display the Quantity or Cost or Value.
What I 've done:
1- I created a "Slicer" element with LUT_ANA [Attribute] value --> with the aim of being able to select 1 of the 3 attributes.
2- I want to create a measure to be plotted which provides me the values of Quantity or Cost or Value respectively depending on which option is flagged in the point 1. In my logic I tried to insert the measure in DATA_TAB but it doesn't work with the following code.
'Version1
Value = SWITCH(ALLSELECTED(LUT_ANA[Attributo] ),
"Quantità",CALCULATE(SUM(DATA_TAB[Quantità])),
"Valore",CALCULATE(SUM(DATA_TAB[Valore])),
"Costo",CALCULATE(SUM(DATA_TAB[Costo])),)
'Version2
Value = SWITCH(
TRUE (),
LUT_ANA[Attributo] = "Quantità",CALCULATE(SUM(DATA_TAB[Quantità])),
LUT_ANA[Attributo] = "Valore",CALCULATE(SUM(DATA_TAB[Valore])),
LUT_ANA[Attributo] = "Costo",CALCULATE(SUM(DATA_TAB[Costo])))
Can someone help me?
Solved! Go to Solution.
@giroldoale , Not very clear. See if these can help to create a measure slicer
https://community.powerbi.com/t5/Desktop/Slicer-MTD-QTD-YTD-to-filter-dates-using-the-slicer/td-p/50...
https://radacad.com/change-the-column-or-measure-value-in-a-power-bi-visual-by-selection-of-the-slic...
@giroldoale , Not very clear. See if these can help to create a measure slicer
https://community.powerbi.com/t5/Desktop/Slicer-MTD-QTD-YTD-to-filter-dates-using-the-slicer/td-p/50...
https://radacad.com/change-the-column-or-measure-value-in-a-power-bi-visual-by-selection-of-the-slic...
User | Count |
---|---|
139 | |
113 | |
103 | |
77 | |
63 |
User | Count |
---|---|
135 | |
126 | |
110 | |
70 | |
61 |