Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi, maybe someone can help me.
The measure that can be seen below, aims to give a color format to the different cells of a variable in a Matrix.
The reality is that it works, but I have a problem.
I have many variables, and when generating each measure for each variable and applying them as a format, the table takes a long time to react.
Maybe there is some way to optimize the measurement.
From already thank you very much.
Solved! Go to Solution.
Hi, @dgiacchino
I can see that [Dist/Min] has been called in this code repetitively. How about saving this measure in a variable? And then use it. This should optimize the memory. And how about calculating the difference between [Dist/min] and [_AvgSession] then storing it in another variable then using it for further calculation? Also, Use SWITCH instead of nested IFs.
something like this:
VAR _DistPerMin = [Dist/min]
VAR _DistDiff = _DistPerMin - _AvgSession
VAR _ColourClassIntraSession =
SWITCH (
TRUE(),
_DistDiff >= 2 * _DstPSession, "#75C050",
_DistDiff >= 1 * _DstPSession, "LightGreen",
_DistDiff >= 0.5 * _DstPSession, "#FFDB41",
_DistDiff >= -0.5 * _DstPSession, "LightYellow",
_DistDiff >= -1 * _DstPSession, "#ECC596",
_DistDiff >= -2 * _DstPSession, "#F29C21",
_DistPerMin > 0, "#EFB5B9",
BLANK ()
)
do the same for _indRefGame. Calculate the difference then use it for calculation. Also in the return statement, you can remove 3 and only use the variable. It should by default return that variable. Right?
Proud to be a Super User!
Use the two measures on 3 variables, only modifying the return option.
It is important to clarify that the data that was compared was the time it takes to load the matrix, after selecting option 1, 2 or 3.
What I could observe, after doing it several times and only having three active variables.
Using the average used by the VAR _RESULTADO, the loading times were 2037, 1638, 1732.
In the other case, the times were 2060, 1874, 1789.
Something important, that I was able to observe, is that even though it improves, the process continues to be slow.
I'm working with parameters, where I included many variables and these format measures affect performance a lot.
Another aspect that may be useful to someone who sees this is that having a dashboard, with many filters, cards, etc. It is essential to use the tool to apply the filters all together, otherwise all the modifications that affect each section are loaded many times.
Hi, @dgiacchino
I can see that [Dist/Min] has been called in this code repetitively. How about saving this measure in a variable? And then use it. This should optimize the memory. And how about calculating the difference between [Dist/min] and [_AvgSession] then storing it in another variable then using it for further calculation? Also, Use SWITCH instead of nested IFs.
something like this:
VAR _DistPerMin = [Dist/min]
VAR _DistDiff = _DistPerMin - _AvgSession
VAR _ColourClassIntraSession =
SWITCH (
TRUE(),
_DistDiff >= 2 * _DstPSession, "#75C050",
_DistDiff >= 1 * _DstPSession, "LightGreen",
_DistDiff >= 0.5 * _DstPSession, "#FFDB41",
_DistDiff >= -0.5 * _DstPSession, "LightYellow",
_DistDiff >= -1 * _DstPSession, "#ECC596",
_DistDiff >= -2 * _DstPSession, "#F29C21",
_DistPerMin > 0, "#EFB5B9",
BLANK ()
)
do the same for _indRefGame. Calculate the difference then use it for calculation. Also in the return statement, you can remove 3 and only use the variable. It should by default return that variable. Right?
Proud to be a Super User!
Do we need to store the result in a variable? we are not using that statement any further to this code right? How about just using return statement? Like this
RETURN SWITCH( _ValorFiltro, 1, _ColourClassIntraSession, 2, _ColorClassSessVsIRG, _ColourClassIntraSession)
see if it improves the performance or not. Would have been better if you could find a way to make it within one switch statement. Just an Idea.
Thanks
Did I help? If yes, hit 👍, accept this solution as the answer.
Proud to be a Super User!
In this optimized code, I have calculated the result of the SWITCH in the _Result variable and then used _Result to return the final result. This avoids duplicating the calculation of _ColourClassIntraSession and improves the overall performance of the measure.
I'm not sure this is entirely correct.
I will compare the two options.
Let me know, I am curious as well
Proud to be a Super User!
Use the two measures on 3 variables, only modifying the return option.
It is important to clarify that the data that was compared was the time it takes to load the matrix, after selecting option 1, 2 or 3.
What I could observe, after doing it several times and only having three active variables.
Using the average used by the VAR _RESULTADO, the loading times were 2037, 1638, 1732.
In the other case, the times were 2060, 1874, 1789.
Something important, that I was able to observe, is that even though it improves, the process continues to be slow.
I'm working with parameters, where I included many variables and these format measures affect performance a lot.
Another aspect that may be useful to someone who sees this is that having a dashboard, with many filters, cards, etc. It is essential to use the tool to apply the filters all together, otherwise all the modifications that affect each section are loaded many times.
Performance was not that much. Can you try to do it within one Switch statement?
Thanks
Proud to be a Super User!
Hi, sorry for the delay.
You mean that the two options swith, and try to generate a single one.
I'm not quite sure how I would do it. If you can generate an example I would appreciate it.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
18 | |
15 | |
12 | |
11 | |
8 |
User | Count |
---|---|
24 | |
19 | |
12 | |
11 | |
10 |