Forum Discussion
Use measure in FILTER function
- 6 years ago
Hi LauraBueno
You'll need to create a disconnected slicer - this is a slicer that won't filter other visuals in your report.
To do this, you need create a new table using the following DAX expression:
DisconnectedTable = ALL ( 'db_datareader Simulation'[Study], 'db_datareader Simulation'[Simulation] )Then create the following measures:
Total Value = SUM ( 'db_datareader Simulation'[Value] )Delta = VAR Sim_Ref = SELECTEDVALUE ( DisconnectedTable[Simulation] ) VAR Value_Ref = CALCULATE ( SUM ( 'db_datareader Simulation'[Value] ), 'db_datareader Simulation'[Simulation] = Sim_Ref ) VAR SumVal = [Total Value] VAR Result = SumVal - Value_Ref RETURN ResultIn your report, add two slicers:
- 'db_datareader Simulation'[Study]
- 'DisconnectedTable'[Simulation]
Then add a table visualisation with the following columns from the 'db_datareader Simulation' table:
- Study
- Simulation
- Type
- Value
- [Delta] measure
You'll find that your Simulation slicer won't automatically filter depending on your selection in the Study slicer.
If you want this to work, you can create the measure below and add it to the Simulation slicer as a visual filter and set the value to 1.
SlicerFilter = VAR SelStudy = SELECTEDVALUE ( 'db_datareader Simulation'[Study] ) VAR SimStudy = SELECTEDVALUE ( DisconnectedTable[Study] ) VAR Result = IF ( SimStudy = SelStudy, 1, 0 ) RETURN ResultThis is the result I got using the data you provided:
Fingers crossed, this will work for you!
Best regards,
Martyn
Hi LauraBueno
Can you provide the full DAX expression in which you're using the FILTER function?
Is it a measure or a calculated column?
Best regards,
Martyn
Hi MartynRamsden,
Thank you for your reply. Please see below the full expression where I'm using FILTER function:
- MartynRamsden6 years agoSolution Sage
Hi LauraBueno
If I understand correctly, you're trying to create a calculated table 'on the fly'? If so, this isn't supported.
Calculated tables (and columns) are only computed when the data is refreshed.
What's your ultimate result? There may be an alternative method to achieve what you're looking for.
Best regards,
Martyn
- LauraBueno6 years agoHelper III
Hi MartynRamsden,
I have a table that looks similar to the one below where I have a study that contains multiple simulations. The variable 'V1' is the output which is measured across different sample types ('column type').
I need to do a simple calculation as follows: V1_i - Vref where V1_i would be the values of all the simulations for a given study a sample type and Vref is the reference simulation selected via a slicer.
So in order to do that I need to be able to put filters by study, simulation and type of sample.
Any ideas how I could do this within this table?
Study Simulation Type V1 1 1 1 23 1 2 1 25 1 3 2 65 1 4 2 72 1 5 3 98 1 6 4 12 1 7 5 5 1 8 6 36 1 9 7 66 1 10 8 35 Thanks
Laura
- MartynRamsden6 years agoSolution Sage
Hi LauraBueno
Are you able to show me an example of your expected output using your sample data?
Best regards,
Martyn