cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

## Create measure that is dependent on slicers in table

I would like to create a measure that can be used in a table as a benchmark or comparison point. However, the measure needs to be dependent on end user slicer selection.

For example, I have collected data on a number of car owners, the cars they have and the colour. Then I have done a series of tests (Test A,b,c). I want to create the comparison value calculation that calculates the max by for each test type depending on what is used in the selection boxes (highlighted in yellow), i.e. if only Yarris and the color red are selected, the comparison measure should return the max value for just that selection (and not take into account name). In the screenshot, the assumption is that all slicer options are selected.

I have attached sample data in a pbix here: https://drive.google.com/file/d/1ib0FAGD-6xt_GueJs-aWzCBtI2bAV9Hm/view?usp=sharing

4 REPLIES 4
Community Support

Hi @JFG123 ,

Best Regards

Community Support Team _ Polly

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support

Hi @JFG123 ,

Create two tables  with the related columns of data.

``Car Type = VALUES('Test Data'[Car Type])``
``Colour = VALUES('Test Data'[Colour])``

Create a measure.

``````maxdata =
var _scar = maxx(FILTER(ALLEXCEPT('Test Data','Test Data'[Test Type]),[Car Type]=SELECTEDVALUE('Car Type'[Car Type])),[Test Value])
var _scol = MAXX(FILTER(ALLEXCEPT('Test Data','Test Data'[Test Type]),[Colour]=SELECTEDVALUE('Colour'[Colour])),[Test Value])
var _sboth = maxx(FILTER(ALLEXCEPT('Test Data','Test Data'[Test Type]),[Colour]=SELECTEDVALUE('Colour'[Colour]) &&[Car Type]=SELECTEDVALUE('Car Type'[Car Type])),[Test Value])
var _sno = MAXX(ALLEXCEPT('Test Data','Test Data'[Test Type]),[Test Value])
return
SWITCH(TRUE(),
SELECTEDVALUE('Car Type'[Car Type])=BLANK() &&SELECTEDVALUE(Colour[Colour])=BLANK(),_sno,
SELECTEDVALUE('Car Type'[Car Type])=BLANK() &&SELECTEDVALUE(Colour[Colour])<>BLANK(),_scol,
SELECTEDVALUE('Car Type'[Car Type])<>BLANK() &&SELECTEDVALUE(Colour[Colour])=BLANK(),_scar,
_sboth)``````

Best Regards

Community Support Team _ Polly

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Super User

@JFG123 , Try if this can help

calculate(Max(Table[Test Value]), allselected())

or

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Frequent Visitor

I have included a sample Pbix file.

The provided soln does not assist, it does not account for;

1. if different names are selected the value changes to reflect the data in the table

2. Doesn't account for the different test type grouping structure

I have added the below image to assist with the interpretation (based on simple sample data). In the initial portion the select for car type is yarris and colour is all. The comparison value is calculated by test type for the data in the table, with no filter on name.

The second portion, shows what should happen after filtering for just JOHN, with the same filters as before, the comparison value shouldnt change just because the name has been filtered down.