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
Nimai123
Post Patron
Post Patron

Measure Taking Lot of Time to Load

I had created a measure to calculate This Year sales and I was applying the below Measure 

This Year Test = SUMX(Main,TOTALYTD(SUMX(Main,SUM([Sales])),'Invoice Date'[Invoice date].[Date]))

 

After clicking on the slicer I am not able to get the answer as it is taking a lot of time to load and sometimes result in an error, and the same time the other measures are working pretty fine!

 

The error name: There's not enough memory to complete this operation. Please try again later when there may be more memory available.

 

 

1 ACCEPTED SOLUTION

@Nimai123 

Why are using sumx two time. You are using totalYTD that will sum of Jan and feb.  TotalMTD give sum of month

Also prefer creating a date table and use that to join

Try like

This Year Test = TOTALYTD(SUM(Table[Sales]),'Invoice Date'[Invoice date])
This Year Test = TOTALYTD(SUM(Table[Sales]),'Date'[Date])

 

And if [Sales] is alreay a measure 

This Year Test = TOTALYTD(([Sales]),'Invoice Date'[Invoice date])
This Year Test = TOTALYTD(([Sales]),'Date'[Date])

 

You can use datesytd and totalytd , few examples

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
last year MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))
last year MTD Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))
last QTR same Month (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,Qtr))))
MTD (Year End) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFYEAR('Date'[Date])))
MTD (Last Year End) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFYEAR(dateadd('Date'[Date],-12,MONTH),"8/31")))

QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date])))
Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,QUARTER)))
Last to last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-2,QUARTER)))
Next QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],1,QUARTER)))
Last year same QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,Year)))

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date]),"12/31"))
This Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD((ENDOFYEAR('Date'[Date])),"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
Last YTD complete Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

 

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

 

View solution in original post

9 REPLIES 9
Pragati11
Super User
Super User

Hi @Nimai123 ,

 

I have created a sample data and I am attaching a sample .pbix file for this. Refer the following link:

                                                                                                                        https://we.tl/t-ov0dug5B6N

 

I have created filteres for Year and Month on this report, just try out if this solution works for you.

Also, in my sample data, the date field is within my sample file. In measures that I created, I have used the same. These can be replaced with the date columns coming from your CALENDAR DATE table.

 

If this helps please give Kudos and mark it as a Solution! 🙂

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

MFelix
Super User
Super User

Hi @Nimai123 ,

 

This is an issue related with nested SUMX.

 

Check the blog post  below with an explanation and ways to surpass this.

 

https://powerpivotpro.com/2015/08/nested-sumx-or-dax-query/


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



If I am using SUM instead of SUMX as below to the above DAX I get the data which is not proper.

This Year Test = SUMX(Main,TOTALYTD(SUM('Main'[Sales]),'Invoice Date'[Invoice date].[Date]))

 

 

 

The problem which I am facing is that if I use SUM on the DAX and when I use slicers on Months I get the data of the total of the months

For Example: If I select February I get the value with the sum of January and February where I should be getting the data of only February. To eliminate this error I used SUM after the TOTALYTD which results in garbage or wrong value.

 

@Nimai123 

Why are using sumx two time. You are using totalYTD that will sum of Jan and feb.  TotalMTD give sum of month

Also prefer creating a date table and use that to join

Try like

This Year Test = TOTALYTD(SUM(Table[Sales]),'Invoice Date'[Invoice date])
This Year Test = TOTALYTD(SUM(Table[Sales]),'Date'[Date])

 

And if [Sales] is alreay a measure 

This Year Test = TOTALYTD(([Sales]),'Invoice Date'[Invoice date])
This Year Test = TOTALYTD(([Sales]),'Date'[Date])

 

You can use datesytd and totalytd , few examples

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
last year MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))
last year MTD Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))
last QTR same Month (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,Qtr))))
MTD (Year End) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFYEAR('Date'[Date])))
MTD (Last Year End) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFYEAR(dateadd('Date'[Date],-12,MONTH),"8/31")))

QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date])))
Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,QUARTER)))
Last to last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-2,QUARTER)))
Next QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],1,QUARTER)))
Last year same QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,Year)))

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date]),"12/31"))
This Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD((ENDOFYEAR('Date'[Date])),"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
Last YTD complete Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

 

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

 

I tried using 

YTD Sales = CALCULATE(SUM(Main[Sales]),DATESYTD(('Invoice Date'[Invoice date].[Date]),"12/31"))

And 

Last YTD Sales = CALCULATE([Total Cost Sumx],DATESYTD(dateadd('Invoice Date'[Invoice date].[Date],-1,Year),"12/31"))

 

I am getting YTD Sales Correct but Wrong output in Last YTD sales, and by using this I am not able to get the sales of the month data as I select May it Sums up all the above months instead of showing the output of only May.

And this measure is not working for the range filter.

 

 

 

This Year Sales = CALCULATE([Total Sales Sumx],DATEADD('Invoice Date'[Invoice date].[Date], 0, year))

Last Year Sales = CALCULATE([This Year Sales],DATEADD('Invoice Date'[Invoice date].[Date], -1,YEAR))

Total Sales Sumx = SUMX(Main,(Main[Sales]))

 

In the above scenario Month, wise is working well shown in the below image but is not working when I use Range filter 

Screenshot (6).png

 

 

 

And my Date column has a relationship with the date column of the main table.

 

 Screenshot (8).png

 

 My Aim is to calculate This year sales and Last Year sales and filter it depending upon the Year, Month, and Range Slicer(Between)

 

@amitchandak 

 

 

 

Can you share sample data and sample output.  Mark me @

My pbix file is large and I will be unable to share it, is it possible that i can show you on teams meeting.

@amitchandak 

I am not able to post a reply due to some error I will be replying you on your personal Chat please have a look 

Thanks in Advance

 

@amitchandak 

I tried using 

YTD Sales = CALCULATE(SUM(Main[Sales]),DATESYTD(('Invoice Date'[Invoice date].[Date]),"12/31"))
And 
Last YTD Sales = CALCULATE([Total Cost Sumx],DATESYTD(dateadd('Invoice Date'[Invoice date].[Date],-1,Year),"12/31"))
 
I am getting YTD Sales Correct but Wrong output in Last YTD sales, and by using this I am not able to get the sales of the month data as I select May it Sums up all the above months instead of showing the output of only May.
 And this measure is not working for the range filter.
 

Screenshot (4).png

 
This Year Sales = CALCULATE([Total Sales Sumx],DATEADD('Invoice Date'[Invoice date].[Date], 0, year))
Last Year Sales = CALCULATE([This Year Sales],DATEADD('Invoice Date'[Invoice date].[Date], -1,YEAR))
Total Sales Sumx = SUMX(Main,(Main[Sales]))
 
 In the above scenario Month, wise is working well shown in the below image but is not working when I use Range filter as shown in the above image.
 
 Screenshot (6).png
 
And my Date column has a relationship with the date column of the main table.
 Screenshot (8).png
 
 My Aim is to calculate This year sales and Last Year sales and filter it depending upon the Year, Month, and Range Slicer(Between)
 
 
 

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.