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 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
Hi LauraBueno
Are you able to show me an example of your expected output using your sample data?
Best regards,
Martyn
- LauraBueno6 years agoHelper III
Hi MartynRamsden,
The picture below shows the sample data I have:
There are several studies and each study with multiple simulations. The variable I am intersted in is 'value' which also depends on the column called 'type'.
What I am trying to do is, 1) Select study via slicer in dashboard (which is link to simulations and hence the slicer for simulations automatically change), 2) Select reference simulation via a different slicer. 3) For the simulation selected in the slicer, I need to do the following calculation:
Value (for all simulations for a fiven study) - Value of simulation selected in slicer filtered by 'Type'.
Could you please help me with this? Thank you so much in advance!
- LauraBueno6 years agoHelper III
- MartynRamsden6 years agoSolution Sage
Hi LauraBueno
Try something like this:
Variance Value = VAR SelValue = SUM ( Table1[Value] ) VAR TotalStudyValue = CALCULATE ( SUM ( Table1[Value] ), ALL ( Table1[Simulation] ) ) VAR Result = TotalStudyValue - SelValue RETURN ResultYou'll need to replace the table and column names with those in your actual model.
Best regards,
Martyn
If I answered your question, please help others by accepting it as a solution.