Forum Discussion
Slicer by columns name
- 9 years ago
Hi Anonymous,
I would solve this using a measure do the following:
- Create a table (do not related this with any other tables with the following structure:
- Name Slicer - Selection: Unity_Price, Tax_1, Tax_2, Tax_3, Tax_4
- Add the following measure to your data table:
Final_Price = VAR Unity_price = IF ( CONTAINS ( Slicer, Slicer[Selection], "Unity_Price" ) = TRUE (), SUM ( Sales[Unity_Price] ), 0 ) VAR Tax1 = IF ( CONTAINS ( Slicer, Slicer[Selection], "Tax_1" ) = TRUE (), SUM ( Sales[Tax_1] ), 0 ) VAR Tax2 = IF ( CONTAINS ( Slicer, Slicer[Selection], "Tax_2" ) = TRUE (), SUM ( Sales[Tax_2] ), 0 ) VAR Tax3 = IF ( CONTAINS ( Slicer, Slicer[Selection], "Tax_3" ) = TRUE (), SUM ( Sales[Tax_3] ), 0 ) VAR Tax4 = IF ( CONTAINS ( Slicer, Slicer[Selection], "Tax_4" ) = TRUE (), SUM ( Sales[Tax_4] ), 0 ) RETURN Unity_price + Tax1 + Tax2 - Tax3 - Tax4- Now just add the valuies from the table you created to a slicer and your measure to the table should give the expected result:
Regards,
MFelix
- Create a table (do not related this with any other tables with the following structure:
Hey Meflix,
I've almost similar issue but I'm not able to resolve it the way you mentioned.
Following are the steps
- Slicer with four different column names
- Select a column name
- Divide the values in column with values in another column present in data
- Use this measure on the graph
I tried following the code you mentioned but instead of Sum(Sales[VAR]) I want Divide(VAR, Column Name)
The code is returning a lot of errors
ETA_Quality =
VAR On_Time =
IF (
CONTAINS ( Slicer, Slicer[V_Selection], "On Time" ) = TRUE (),
Divide( 'Volvo ETA'[On-Time], 'Volvo ETA'[Total], Blank()),
0
)
VAR Early =
IF (
CONTAINS ( Slicer, Slicer[V_Selection], "Early" ) = TRUE (),
Divide( 'Volvo ETA'[Early], 'Volvo ETA'[Total], Blank()),
0
)
VAR Late =
IF (
CONTAINS ( Slicer, Slicer[V_Selection], "Late" ) = TRUE (),
Divide( 'Volvo ETA'[Late], 'Volvo ETA'[Total], Blank()),
0
)
VAR Cancelled =
IF (
CONTAINS ( Slicer, Slicer[V_Selection], "Cancelled" ) = TRUE (),
CALCULATE( 'Volvo ETA'[Cancelled] 'Volvo ETA'[Total], Blank()),
0
) Return Cancelled+Early+Late+On_Time
Also instead of last Return Cancelled+Early+Late+On_Time, I just want to Return all of them which will eventually display the VAR value based on Column Selection.
Thanks!
Hi Anonymous,
When you use measure they are calculated based on context so you cannot make the calculations based on a single value from a colum, meaning that when you have
VAR On_Time = IF ( CONTAINS ( Slicer, Slicer[V_Selection], "On Time" ) = TRUE (), Divide( 'Volvo ETA'[On-Time], 'Volvo ETA'[Total], Blank()), 0 )
You should have something like this:
VAR On_Time =
IF (
CONTAINS ( Slicer, Slicer[V_Selection], "On Time" ) = TRUE (),
DIVIDE ( SUM ( 'Volvo ETA'[On-Time] ), SUM ( 'Volvo ETA'[Total] ), BLANK () ),
0
)In this way you are aggregating the values, however be carefull because this can sometimes based on context not return the expected result.
Can you please share some sample data and show the expected result in that way I can adjust the formula better.
Regards,
MFelix
- Anonymous8 years agoNot applicable
Hey MFelix ,
Thanks for the reply. I realised the issue now and almost fixed it. Also what are you tryiig to say in the first step? I created a different table with all the four columns in it named Early, Late, Cancelled, On Time but I cannot still add the slicer which gives me all column names in the selection. Can you explain the first step a little more?
It's giving me this error:
Failed to resolve name 'Slicer'. It is not a valid table, variable, or function name.
Thanks!
Niket
- MFelix8 years ago
Super User
Hi Anonymous,
In the previous post the name of the table was Slicer that's why it's in the formula.
You need to place the name of the table you used to make the slicer selection.
Regards,
MFelix
- Smitaa3 years agoNew Member
Hi MFelix,
I want to create a slicer of multiple columns based on another slicer having parameters.
for example raw data is like this:
Event Student ID Maths teacher Science Teacher English Teacher Exhibition 1 Ravi Chandra Spriha Das Vandana p Exhibition 2 RK Das Mamta Chobey Exhibition 3 Rajesh Ranjan Rajesh Ranjan So first slicer should have values like Maths, Science and English:
Slicer 1 Maths Science English And second slicer should filter based on Slicer 1 for example if Maths is selected in slicer 1 , then slicer 2 should have following values:
Slicer 2 Ravi Chandra RK Das And table should show this:
Event Student ID Maths teacher Exhibition 1 Ravi Chandra Exhibition 2 RK Das I tried with field parameters but it cant be used in report server
Please help me with this.