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
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- LauraBueno6 years agoHelper III
Hi V-lianl-msft ,
Thank you for your message. I did try the solution described in the post you shared. However, it is not completely working for me.
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!