Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello everyone,
I have the following measure in Live connection in Power BI desktop:
Variation =
VAR Code_T = 1600
VAR Code_T_1 = 1500
VAR SUM_T = CALCULATE([Measure1];Table[Code_Column] = Code_T)
VAR SUM_T_1= CALCULATE([Measure2];Table[Code_Column] = Code_T_1)
return SUM_T - SUM_T_1
Code_T and Code_T-1 are the max and second max respectively of Code_Column, for each of these I calculate the [Measure1] and [Measure2] that already exists in the model.
If I hardcode the values 1600 and 1500 this works really well.
But instead of hardcoding the values I would like them to be dynamic so I would like to put the max value of Code_Column in Code_T, instead of 1600, and put the second max value of Code_Column in Code_T_1, instead of 1500.
I tried the following but with no success:
Variation =
VAR Code_T = MAX(Code_Column)
VAR Code_T_1 = CALCULATE(MAX(Table[Code_Column]);Table[Code_Column] < Code_T)
VAR SUM_T = CALCULATE([Measure1];Table[Code_Column] = Code_T)
VAR SUM_T_1= CALCULATE([Measure2];Table[Code_Column] = Code_T_1)
return SUM_T - SUM_T_1
Any ideas? I'm kind of new to DAX.
Thank you.
Hi @Anonymous
Can we have a data sample?
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
7 | |
7 | |
6 | |
6 |
User | Count |
---|---|
27 | |
12 | |
10 | |
9 | |
6 |