Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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, @Anonymous 

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, @Anonymous 

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.