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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Compare Last year months data VS this year Months

Hello, 
 
I have created two formulas to compare last year month vs this year months sales data. It works fine, but when it comes to future month(2018) it will show me the same value as last year instead of blank. Can anybody please tell me how to fix this or any better way to get do this? 
 
Sales This Year = TOTALYTD(SUM(SalesDetails[Sales]),SalesDetails[Invoices.Day])
Sales Last Year = CALCULATE([Total Sales],SAMEPERIODLASTYEAR(Calendar_dim[Date]))

After March 2018 should be  blank, but it is not.After March 2018 should be blank, but it is not.

 Thank you so much

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

In my opinion, the issue is related to your chart axis. The Axis in your chart is MonthNameLong which only shows the month. It also means, your chart cannot tell which year the month belongs to. As in your source table, there exists data in April 2017. So there will exist data in April.

 

To resolve your issue, please try to add Year and Month as Axis in chart.

 

Thanks,
Xi Jin.

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

 

Try this

 

Sales This Year = IF(ISBLANK(SUM(SalesDetails[Sales])),BLANK(),TOTALYTD(SUM(SalesDetails[Sales]),Calendar_dim[Date]))

 

Ensure that the months appearing in your visual are from the Calendar_dim table.

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

@Ashish_Mathur

 

Hello Ashish, 

 

Thank you so much for the help. when I use the date from calendar instead of date from sales it will not accurate somehow. Please look at the file below. I tried what you have suggested, still the same. 

 

 

 

Thank you so much 

Hi,

 

Reduce that file size to a couple of MB's please.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

@Ashish_Mathur

 

Hello, 

 

I really appreciate your help.  I have deleted some records and you can see it from HERE. I think I reduce the file size to less than 3.5 MB. 

 

Thank you so much 

 

Hi @Anonymous,

 

In my opinion, the issue is related to your chart axis. The Axis in your chart is MonthNameLong which only shows the month. It also means, your chart cannot tell which year the month belongs to. As in your source table, there exists data in April 2017. So there will exist data in April.

 

To resolve your issue, please try to add Year and Month as Axis in chart.

 

Thanks,
Xi Jin.

Anonymous
Not applicable

@v-xjiin-msft

 

Hey Xi Jin,

 

Thank you so much for the advice. When I Just add sales to measures and drag year into legend it will fix my issue. 

 

Again, thank you 

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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