Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
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.