Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
giroldoale
Helper I
Helper I

Switch Issue

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.CodeQuantityValueCost
A23312123123121231234
B1231313441412
C215621
............

 

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?

1 ACCEPTED SOLUTION
1 REPLY 1

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.