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.
Dear community,
I am relatively new to Power BI and I am trying to create a measure that will help me calculate a national student score based on the high school level recommendation they were given in elementary school.
High school level recommendation in our country (Netherlands) is ranked as follows (starting from low to high). There can also be a mixed advice (see 3, 5, 7, 9). I have already made an index column with this exact numbering.
The national student score is calculated using the students current high school level in year number 3 by the following conditions.
Below is an example of an imaginary school, in the first column are the recommendations, and in the 2nd to 7th column are the number of students that achieved the corresponding high school level.
I am trying to achieve the following as the national student score is dependant on the recommendation that is given.
IF recommendation = 1(e.g. pro), then the sum of every table (since it is a higher level) is added.
IF recommendation = 2(e.g. vmbo b), then the sum of vmbo k, vmbo (g)t, havo, havo/vwo and vwo is added since the count of vmbo b is neutral.
IF recommendation = 3, then the sum of vmbo k, vmbo (g)t, havo, havo/vwo and vwo is added since the count of vmbo b is neutral.
IF recommendation = 4, then the sum of vmbo (g)t, havo, havo/vwo and vwo is added since the count of vmbo k is neutral. This sum is then subtracted by the count of vmbo b, because this is a lower level.
and so on.
I want to write a specific measure that takes into account all these calculations per row. The national student score column should then contain a specific score per recommendation. See column 8 for the desired result.
Recommendation | vmbo b | vmbo k | vmbo (g)t | havo | havo/vwo | vwo | National student score (desired result) |
vmbo k | 0 | 0 | 1 | 0 | 0 | 0 | 1 |
vmbo k / (g)t | 0 | 0 | 2 | 0 | 0 | 0 | 2 |
vmbo (g)t / havo | 0 | 0 | 79 | 19 | 0 | 1 | 20 |
havo | 0 | 0 | 27 | 107 | 0 | 23 | -4 |
havo/vwo | 0 | 0 | 2 | 2 | 0 | 1 | -1 |
vwo | 0 | 0 | 1 | 16 | 0 | 139 | -17 |
I am very much looking forward to any tips that can guide me in the right direction.
Many thanks,
S
Solved! Go to Solution.
Hi @blessedberry,
You can create a variable table in formula with all recommendation and level mapping and use it to get the current level, then you can write expression with if statement based on current level to calculate across the field.
formula =
VAR currentR =
SELECTEDVALUE ( Table[Recommendation] )
VAR dictR =
UNION (
SELECTCOLUMNS ( { "pro" }, "Recommendation", [Value], "Level", 1 ),
SELECTCOLUMNS ( { "vmbo b" }, "Recommendation", [Value], "Level", 2 ),
SELECTCOLUMNS ( { "vmbo k" }, "Recommendation", [Value], "Level", 3 ),
SELECTCOLUMNS ( { "vmbo g" }, "Recommendation", [Value], "Level", 4 )
)
VAR currLevel =
MAXX ( FILTER ( dictR, [Recommendation] = currentR ), [Level] )
RETURN
IF ( currLevel <= 1, SUM ( Table[vmbo b] ) )
+ IF ( currLevel <= 2, SUM ( Table[vmbo k] ) )
+ IF ( currLevel <= 3, SUM ( Table[vmbo (g)t] ) )
+ IF (
currLevel <= 4,
SUM ( Table[havo] ) + SUM ( Table[vwo] )
+ SUM ( Table[vwo] )
)
Regards,
Xiaoxin Sheng
Hi @blessedberry,
You can create a variable table in formula with all recommendation and level mapping and use it to get the current level, then you can write expression with if statement based on current level to calculate across the field.
formula =
VAR currentR =
SELECTEDVALUE ( Table[Recommendation] )
VAR dictR =
UNION (
SELECTCOLUMNS ( { "pro" }, "Recommendation", [Value], "Level", 1 ),
SELECTCOLUMNS ( { "vmbo b" }, "Recommendation", [Value], "Level", 2 ),
SELECTCOLUMNS ( { "vmbo k" }, "Recommendation", [Value], "Level", 3 ),
SELECTCOLUMNS ( { "vmbo g" }, "Recommendation", [Value], "Level", 4 )
)
VAR currLevel =
MAXX ( FILTER ( dictR, [Recommendation] = currentR ), [Level] )
RETURN
IF ( currLevel <= 1, SUM ( Table[vmbo b] ) )
+ IF ( currLevel <= 2, SUM ( Table[vmbo k] ) )
+ IF ( currLevel <= 3, SUM ( Table[vmbo (g)t] ) )
+ IF (
currLevel <= 4,
SUM ( Table[havo] ) + SUM ( Table[vwo] )
+ SUM ( Table[vwo] )
)
Regards,
Xiaoxin Sheng
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
26 | |
10 | |
10 | |
9 | |
6 |