Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Good morning, I have this formula that works perfectly, but it takes a long time to load every time I apply a filter. About 20 seconds on average. My question is if it can be optimized in such a way that it does not take so long to load, I am quite new and I know that there would be infinite paths but I can not think of anything else. Thank you very much in advance.
Using variables should speed it up
RANKING POINTS FAST =
IF (
ISFILTERED ( 'TABLE OF DATES'[Nº WEEK AND MONTH] )
|| ISFILTERED ( 'TABLE OF DATES'[DAY MONTH] ),
VAR SalesOnlyBA = [SALES ONLY BA]
VAR MaxBANecessary =
MAX ( 'WEEKLY INCENTIVES'[BA. A NECESSARY] )
RETURN
IF (
CALCULATE (
RANKX ( ALL ( 'AGENTS AND SCHEDULES'[AGENT] ), [POINTS],, DESC, SKIP ),
'WEEKLY INCENTIVES'[SHIFT ONL/RFZ/TLV] = "ONLINE"
) = 1
&& SalesOnlyBA >= MaxBANecessary
|| CALCULATE (
RANKX ( ALL ( 'AGENTS AND SCHEDULES'[AGENT] ), [POINTS],, DESC, SKIP ),
'WEEKLY INCENTIVES'[SHIFT ONL/RFZ/TLV] = "REINFORCEMENT"
) = 1
&& SalesOnlyBA >= MaxBANecessary
|| CALCULATE (
RANKX ( ALL ( 'AGENTS AND SCHEDULES'[AGENT] ), [POINTS],, DESC, SKIP ),
'WEEKLY INCENTIVES'[SHIFT ONL/RFZ/TLV] = "TELESHOPPING"
) = 1
&& SalesOnlyBA >= MaxBANecessary,
" :heavy_dollar_sign: Cobra, has " & ROUND ( [POINTS], 1 ) & " points and superavit of " & SalesOnlyBA - MaxBANecessary & "sales",
IF (
SalesOnlyBA >= MaxBANecessary
&& SalesOnlyBA > 0,
":cross_mark:No cobra, has " & ROUND ( [POINTS], 1 ) & " points and superavit of " & SalesOnlyBA - MaxBANecessary & "sales",
":cross_mark:No cobra, has " & ROUND ( [POINTS], 1 ) & " points and missing "
& ABS ( MaxBANecessary - SalesOnlyBA ) & "sales"
)
),
BLANK ()
)
This formula has improved only one second the original but something is something, the effort is appreciated.
Hi @Syndicate_Admin ,
You could try below code :-
RANKING POINTS FAST =
IF (
OR (
ISFILTERED ( 'TABLE OF DATES'[Nº WEEK AND MONTH] ),
ISFILTERED ( 'TABLE OF DATES'[DAY MONTH] )
),
IF (
CALCULATE (
RANKX ( ALL ( 'AGENTS AND SCHEDULES'[AGENT] ), [POINTS],, DESC, SKIP ),
FILTER (
'WEEKLY INCENTIVES',
'WEEKLY INCENTIVES'[SHIFT ONL/RFZ/TLV] = "ONLINE"
)
) = 1
&& [SALES ONLY BA] >= MAX ( 'WEEKLY INCENTIVES'[BA. A NECESSARY] )
|| CALCULATE (
RANKX ( ALL ( 'AGENTS AND SCHEDULES'[AGENT] ), [POINTS],, DESC, SKIP ),
FILTER (
'WEEKLY INCENTIVES',
'WEEKLY INCENTIVES'[SHIFT ONL/RFZ/TLV] = "REINFORCEMENT"
)
) = 1
&& [SALES ONLY BA] >= MAX ( 'WEEKLY INCENTIVES'[BA. A NECESSARY] )
|| CALCULATE (
RANKX ( ALL ( 'AGENTS AND SCHEDULES'[AGENT] ), [POINTS],, DESC, SKIP ),
FILTER (
'WEEKLY INCENTIVES',
'WEEKLY INCENTIVES'[SHIFT ONL/RFZ/TLV] = "TELESHOPPING"
)
) = 1
&& [SALES ONLY BA] >= MAX ( 'WEEKLY INCENTIVES'[BA. A NECESSARY] ),
" :heavy_dollar_sign: Cobra, has " & ROUND ( [POINTS], 1 ) & " points and superavit of "
& [SALES ONLY BA] - MAX ( 'WEEKLY INCENTIVES'[BA. A NECESSARY] ) & "sales",
IF (
[SALES ONLY BA] >= MAX ( 'WEEKLY INCENTIVES'[BA. A NECESSARY] )
&& [SALES ONLY BA] > 0,
":cross_mark:No cobra, has " & ROUND ( [POINTS], 1 ) & " points and superavit of "
& [SALES ONLY BA] - MAX ( 'WEEKLY INCENTIVES'[BA. A NECESSARY] ) & "sales",
":cross_mark:No cobra, has " & ROUND ( [POINTS], 1 ) & " points and missing "
& ABS ( MAX ( 'WEEKLY INCENTIVES'[BA. A NECESSARY] ) - [SALES ONLY BA] ) & "sales"
)
),
BLANK ()
)
and you can also try to keep your all calculate code in the seperate variables and use it in If condition.
Thanks,
Samarth
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
@Syndicate_Admin You can also try this:-
RANKING POINTS FAST =
VAR _caseOnline =
CALCULATE (
RANKX ( ALL ( 'AGENTS AND SCHEDULES'[AGENT] ), [POINTS],, DESC, SKIP ),
FILTER (
'WEEKLY INCENTIVES',
'WEEKLY INCENTIVES'[SHIFT ONL/RFZ/TLV] = "ONLINE"
)
)
VAR _caseREINFORCEMENT =
CALCULATE (
RANKX ( ALL ( 'AGENTS AND SCHEDULES'[AGENT] ), [POINTS],, DESC, SKIP ),
FILTER (
'WEEKLY INCENTIVES',
'WEEKLY INCENTIVES'[SHIFT ONL/RFZ/TLV] = "REINFORCEMENT"
)
)
VAR _caseTELESHOPPING =
CALCULATE (
RANKX ( ALL ( 'AGENTS AND SCHEDULES'[AGENT] ), [POINTS],, DESC, SKIP ),
FILTER (
'WEEKLY INCENTIVES',
'WEEKLY INCENTIVES'[SHIFT ONL/RFZ/TLV] = "TELESHOPPING"
)
)
RETURN
IF (
OR (
ISFILTERED ( 'TABLE OF DATES'[Nº WEEK AND MONTH] ),
ISFILTERED ( 'TABLE OF DATES'[DAY MONTH] )
),
IF (
AND (
OR (
_caseReinforcement = 1
&& [SALES ONLY BA] >= MAX ( 'WEEKLY INCENTIVES'[BA. A NECESSARY] ),
OR (
_caseREINFORCEMENT = 1
&& [SALES ONLY BA] >= MAX ( 'WEEKLY INCENTIVES'[BA. A NECESSARY] ),
_caseTeleshopping = 1
)
),
[SALES ONLY BA] >= MAX ( 'WEEKLY INCENTIVES'[BA. A NECESSARY] )
),
" :heavy_dollar_sign: Cobra, has " & ROUND ( [POINTS], 1 ) & " points and superavit of "
& [SALES ONLY BA] - MAX ( 'WEEKLY INCENTIVES'[BA. A NECESSARY] ) & "sales",
IF (
AND (
[SALES ONLY BA] >= MAX ( 'WEEKLY INCENTIVES'[BA. A NECESSARY] ),
[SALES ONLY BA] > 0
),
":cross_mark:No cobra, has " & ROUND ( [POINTS], 1 ) & " points and superavit of "
& [SALES ONLY BA] - MAX ( 'WEEKLY INCENTIVES'[BA. A NECESSARY] ) & "sales",
":cross_mark:No cobra, has " & ROUND ( [POINTS], 1 ) & " points and missing "
& ABS ( MAX ( 'WEEKLY INCENTIVES'[BA. A NECESSARY] ) - [SALES ONLY BA] ) & "sales"
)
),
BLANK ()
)
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
In this way the loading time has been significantly lowered.
Thanks a lot
Hi @vicjordan
Please try this formula. It may be faster.
RANKING POINTS FAST =
IF (
ISFILTERED ( 'TABLE OF DATES'[Nº WEEK AND MONTH] )
|| ISFILTERED ( 'TABLE OF DATES'[DAY MONTH] ),
VAR SalesOnlyBA = [SALES ONLY BA]
VAR MaxBANecessary =
MAX ( 'WEEKLY INCENTIVES'[BA. A NECESSARY] )
RETURN
IF (
SalesOnlyBA >= MaxBANecessary,
IF (
CALCULATE (
RANKX ( ALL ( 'AGENTS AND SCHEDULES'[AGENT] ), [POINTS],, DESC, SKIP ),
'WEEKLY INCENTIVES'[SHIFT ONL/RFZ/TLV] = "ONLINE"
) = 1
|| CALCULATE (
RANKX ( ALL ( 'AGENTS AND SCHEDULES'[AGENT] ), [POINTS],, DESC, SKIP ),
'WEEKLY INCENTIVES'[SHIFT ONL/RFZ/TLV] = "REINFORCEMENT"
) = 1
|| CALCULATE (
RANKX ( ALL ( 'AGENTS AND SCHEDULES'[AGENT] ), [POINTS],, DESC, SKIP ),
'WEEKLY INCENTIVES'[SHIFT ONL/RFZ/TLV] = "TELESHOPPING"
) = 1,
" :heavy_dollar_sign: Cobra, has " & ROUND ( [POINTS], 1 ) & " points and superavit of " & SalesOnlyBA - MaxBANecessary & "sales",
IF (
SalesOnlyBA > 0,
":cross_mark:No cobra, has " & ROUND ( [POINTS], 1 ) & " points and superavit of " & SalesOnlyBA - MaxBANecessary & "sales",
":cross_mark:No cobra, has " & ROUND ( [POINTS], 1 ) & " points and missing "
& ABS ( MaxBANecessary - SalesOnlyBA ) & "sales"
)
)
)
)
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
93 | |
85 | |
84 | |
73 | |
49 |
User | Count |
---|---|
142 | |
133 | |
110 | |
68 | |
55 |