Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Measure with a variable

Hi,

 

I am trying to upgrade a company report such that it is future proof. I am currently facing a seemingly simple problem which has been bugging me for the past 2 days. I can't share the data but I'll try to sketch the scenario as well as possible.

 

My data consists of many rows and columns, which are divided according to the following example:

 

table 1

 ClassValueSlicer columns
1A1Fullfills requirements
2A2Fullfills requirements
3A3Bad solution
4B4Fullfills requirements
5B5Bad solution
6C6Fullfills requirements
7C7Bad solution

 

Users give input in the various columns, which results in a solution meeting the requirements or not (here sumarized in a column, in the real report, this is done through slicers in the project). I want to find the maximum of the valid solutions per class, but at the same time I want to find the minimum of all the maximums (which is my most conservative solution to the problem). e.g. The maximum acceptable values are (2, 4 and 6), so my measure should output 2, which is the minimum of the 3 maximums.

 

My measure which does this, is as follows (I left the good/bad solution filter out for simplicity):

measure =

VAR maxA = CALCULATE(MAX(table1[Value]); table1[Class] = "A")

VAR maxB = CALCULATE(MAX(table1[Value]); table1[Class] = "B")

VAR maxC = CALCULATE(MAX(table1[Value]); table1[Class] = "C")

RETURN MIN(MIN(maxA;maxB) ; maxC)

 

This measure does exactly as expected. However, the amount of classes in my data can change in the future. Hence, I would like to include a loop over a variable amount of classes instead of hard coding them.

 

The slicer criteria are set inside the report. Therefore, I cannot use the query editor, as that does all the calculations while loading the data, therefore ignoring future slicers (at least to my understanding, correct me if I am wrong). I think I am limited to using a measure, but those don't work well with variables/functions.

 

I hope someone can help me out.

 

Cheers,

 

Jeffrey

2 ACCEPTED SOLUTIONS
az38
Community Champion
Community Champion

Hi @Anonymous 

it looks like you need MINX() function like

Measure = 
CALCULATE(
MINX('Table',
CALCULATE(MAX('Table'[Value]),ALLEXCEPT('Table','Table'[Class]))),
ALL('Table')
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

Anonymous
Not applicable

2 REPLIES 2
Anonymous
Not applicable

Here's the full and correct solution:

https://1drv.ms/u/s!ApyQEauTSLtOgYM665_GXHuUZylVyw?e=IQUTF8

Best
D
az38
Community Champion
Community Champion

Hi @Anonymous 

it looks like you need MINX() function like

Measure = 
CALCULATE(
MINX('Table',
CALCULATE(MAX('Table'[Value]),ALLEXCEPT('Table','Table'[Class]))),
ALL('Table')
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.