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
Deeins
New Member

Calculate Last year sales with the Date Slicer

Hi All,

 

I am creating a powerbi report to see this year and last year sales.

 

I have Slicer for date filter, so that I want to see this year Sales and last year Sales. 

 

I used the Dax measure : 

Last year = CALCULATE(
    SUM(maintable[total_sale_amount]),
    SAMEPERIODLASTYEAR(maintable[delivery_date])
)

but unfortunately I am getting the below format, I am getting the values for each date, but not for year and , 'month'year' 

Deeins_1-1680134108407.png

 

and my rows are as below:

Deeins_2-1680134162043.png

where 

Year = year(MainTable[delivery_date])
Month & Year = FORMAT('Maintable'[delivery_date],"MMM 'YY")

 

I was wondering if there ia way to fix this.
Any help is much appreciated! Thank you

 

2 REPLIES 2
Deeins
New Member

@amitchandak Thank you for your response. 

 

Unfortunately, I tried changing the date but still having the same issue! 

amitchandak
Super User
Super User

@Deeins , You have to use date table, marked as date table having 1-m Join with you table 

 

Last year = CALCULATE(
SUM(maintable[total_sale_amount]),
SAMEPERIODLASTYEAR(Date[Date])
)

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...
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 :radacad sqlbi My Video Series Appreciate your Kudos.

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.