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.
Hi everyone,
I have a report with 4 visuals. One of them works without SAMEPERIODLASTYEAR and it's DAX query takes 75ms. But the other 3 takes at least 300ms. Debugging the slowest query I see this huge union:
((SELECT CAST( '20190301 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190302 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190303 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190304 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190305 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190306 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190307 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190308 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190309 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190310 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190311 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190312 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190313 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190314 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190315 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190316 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190317 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190318 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190319 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190320 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190321 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190322 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190323 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190324 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190325 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190326 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190327 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190328 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190329 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190330 00:00:00' AS datetime) AS [c94] ) UNION ALL
(SELECT CAST( '20190331 00:00:00' AS datetime) AS [c94] ) )
Can be this the reason for those times?
Is there a way to avoid all this SELECT CAST?
I don't know what can I do to solve this problem.
My database has a date table, with datetime format.
Do you know other ways to calculate SAMEPERIODLASTYEAR? I tried DATEADD(date, -1, YEAR) and returns the same SQL query.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
47 | |
26 | |
19 | |
14 | |
10 |
User | Count |
---|---|
58 | |
50 | |
44 | |
19 | |
18 |