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.
Hi every one, i would like to know if it is possible to simplify my code.
The time spent is way too long and i don't know any alternative to do the same thing but way faster with less if statments.
My code :
Solved! Go to Solution.
There are a few things you can do to clean up the code which will make it easier to read and maintain and also improved performance.
Instead of using FIRSTDATE use MIN. FIRSTDATE returns a table, MIN returns a scalar value and you are using it as a scalar value.
Retrieve all the min dates only once and store them in variables. Currently you have to calculate each minimum date twice, which will impact on performance.
Rather than using the nested IF statements, which are impossible to read, use the pattern
SWITCH( TRUE(),
Condition 1, Result 1,
Condition 2, Result 2,
Default result
)
You could also store the result of the [Email confirmes] measure in a variable, as you are using that twice as well.
There are a few things you can do to clean up the code which will make it easier to read and maintain and also improved performance.
Instead of using FIRSTDATE use MIN. FIRSTDATE returns a table, MIN returns a scalar value and you are using it as a scalar value.
Retrieve all the min dates only once and store them in variables. Currently you have to calculate each minimum date twice, which will impact on performance.
Rather than using the nested IF statements, which are impossible to read, use the pattern
SWITCH( TRUE(),
Condition 1, Result 1,
Condition 2, Result 2,
Default result
)
You could also store the result of the [Email confirmes] measure in a variable, as you are using that twice as well.
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
9 | |
7 | |
6 | |
6 |
User | Count |
---|---|
28 | |
11 | |
11 | |
10 | |
6 |