cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
noahh
Helper I
Helper I

Dax Optimization - Formula Improvement Help

Can someone help me optimize this first part of my Meausre? It has to be dynamic which is why I have to do it in a measure. The first thing I have to do is take my "Date_Date" column and for each date join with 60 days of invoicing. That is what the code below is doing but it is super slow. Any suggestions on how to speed it up? So a small example of my "virtual" table in dax would be this. Any help would be greatly apprciated.

1/1/2021 1/1/2021
1/1/2021 1/2/2021
1/1/2021 1/3/2021
1/1/2021 1/4/2021
1/2/2021 1/2/2021
1/2/2021 1/3/2021
1/2/2021 1/4/2021
1/2/2021 1/5/2021

 

 

GENERATE (
SELECTCOLUMNS (
CALCULATETABLE (
VALUES ( 'Date'[Date_Date] ),
FILTER (
ALL ( 'Date'[Date_Invoicing_Day_FLG] ),
'Date'[Date_Invoicing_Day_FLG] = 1
),
CROSSFILTER ( 'Date'[Date_Key], 'Sales Order Table'[Created Date Key], BOTH )
),
"Help", 'Date'[Date_Date]
),
CALCULATETABLE (
VALUES ( 'Date'[Date_Date] ),
FILTER (
ALL ( 'Date'[Date_Date], 'Date'[Date_Invoicing_Day_FLG] ),
'Date'[Date_Date]
<= EARLIER ( [Help] ) + 60
&& 'Date'[Date_Date] >= EARLIER ( [Help] )
&& 'Date'[Date_Invoicing_Day_FLG] = 1
)
)
)
1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @noahh 

According to your DAX formula, you used the table operation functions like “GENERATE”, “CROSSFILTER”,” Filter”, which will work for each row the measure is calculated. I think this will take plenty of time if the data amount is very large.

 

Maybe you can avoid generating virtual tables more than once to speed up the calculation of the measure if it’s possible. It’s also feasible if you can use the entity table to replace some of the virtual tables. You can also refer to this document to get some suggestions for improving Power BI Performance by Optimizing DAX:

https://maqsoftware.com/expertise/powerbi/dax-best-practices

 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-robertq-msft
Community Support
Community Support

Hi, @noahh 

According to your DAX formula, you used the table operation functions like “GENERATE”, “CROSSFILTER”,” Filter”, which will work for each row the measure is calculated. I think this will take plenty of time if the data amount is very large.

 

Maybe you can avoid generating virtual tables more than once to speed up the calculation of the measure if it’s possible. It’s also feasible if you can use the entity table to replace some of the virtual tables. You can also refer to this document to get some suggestions for improving Power BI Performance by Optimizing DAX:

https://maqsoftware.com/expertise/powerbi/dax-best-practices

 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.