Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi,
Thanks for your help in advance!
Some of my visuals/tables are taking ~1 minute to load, how can I reduce the loading time?
Maximum time is taken by line chart by week.
I have similar structured DAX as follows to switch between weekly, YTD, LTM, followed by respective YoYs. An example is shown below:
Current time period DAX:
sales_current =
Previous time period DAX:
sales_ly =
var sales_wk_prev = CALCULATE( [SALES_SUM], SALES[WEEK] = wk, SALES[YEAR] = prev_yr )
var sales_ytd_prev = CALCULATE([SALES_SUM], SALES[YEAR] = prev_yr, SALES[WEEK] <= wk, SALES[MONTH] <= mn )
var sales_ltm_prev = CALCULATE( [SALES_SUM] , SALES[WEEK_CONSECUTIVE] >= prv_wknm - 52, SALES[WEEK_CONSECUTIVE] <= prv_wknm )
return
SWITCH( TRUE(),
SELECTEDVALUE(SALES_TIME_PERIODS[TIME_PERIODS])= "Week", FIXED(sales_wk_prev,0,0),
SELECTEDVALUE(SALES_TIME_PERIODS[TIME_PERIODS])= "YTD", FIXED(sales_ytd_prev,0,0),
SELECTEDVALUE(SALES_TIME_PERIODS[TIME_PERIODS])= "LTM", FIXED(sales_ltm_prev,0,0) )
YoY:
yoy = ( sales_current - sales_ly ) / sales_ly
I have multiple KPIs and YoYs (~20 columns) in the matrix which is taking a lot of time to load. Maximum time is taken by a line chart by week which has 2 KPIs. The backend fact data consists of 12million+ rows.
Will adding filter( all( ..... ) .... .... ) in calculate help? or any other step?
Kindly help me to reduce the loading time. Please let me know if more information is needed.
Thanks
Before digging too far into the DAX, I'd recommend looking up and researching field parameters for Power BI: Use report readers to change visuals (preview) - Power BI | Microsoft Learn. It looks like this could solve many problems and simplify the DAX you've made if you implement some date field parameters (Month, Year, Week, etc.). This way, you don't have to calculate each range individually and can just do a single calculation.
Also, try to use the FILTER function with AND or OR to help reduce execution time. var sales_ltm_prev can be re-written as:
CALCULATE(
[SALES_SUM] ,
FILTER(
VALUES(
SALES[WEEK_CONSECUTIVE]
),
AND(
SALES[WEEK_CONSECUTIVE] >= prv_wknm - 52,
SALES[WEEK_CONSECUTIVE] <= prv_wknm
)
)
)
which could help speed up that query significantly.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
User | Count |
---|---|
24 | |
16 | |
12 | |
12 | |
8 |
User | Count |
---|---|
31 | |
24 | |
16 | |
15 | |
12 |