cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
zibster
Helper III
Helper III

Same period last year

Hi Can anyone tell me how to fix my DAX, when I filter year my last year is not populating,

 

LY = CALCULATE(SUM(Sales[Sales]),
FILTER(
ALL(Sales),
Sales[txn_dte]=SAMEPERIODLASTYEAR(Sales[txn_dte].[Date])
)
)
 
Thanks
Z
1 ACCEPTED SOLUTION

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


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

View solution in original post

29 REPLIES 29

Hi,

I'll need to see your PBI file.


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

Hi Ashish, 

 

Please find my PBIx file in Here 

 

Thanks in Advance!

 

 

Hi,

The relationships seem OK to me (just change the cardinality from Both to Single) however something strange is that when i remove fields of the Invoice Table from the Table visual (so only Date and ID [from the SupplierList Table] remain), then the Date field does not show any dates.  This prompts me to believe that the Created Date column on the SupplierList Table is problematic.  In the Query Editor, you will have to format those as dates.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
niteshtrehan89
Helper III
Helper III

Hi

Can you try the below dax

LY Sales = CALCULATE(sum(sales[Sales]), SAMEPERIODLASTYEAR(Sales[txn_dte]))

 

 

Anonymous
Not applicable

I think Evan's suggestion above was correct - with one addition.  I'd create the sales measure and then the measure he suggested but after add in - ALL(Date) so.......LY Sales = CALCULATE([Sales], SAMEPERIODLASTYEAR(Sales[txn_dte].[Date]), ALL(txn_dte) )

His should have worked though....

Evan4
Frequent Visitor

Hi,

Have you made sure your calendar table has been marked as a 'Date' table? You'll also want to make sure that this filed is marked as a 'Date' field as well.

Try that and let us know how you go.

Thanks!

Hi The dates ate all on the same table as the sales amounts and the column is set to date format.

 

image.png

 

Thanks

Evan4
Frequent Visitor

Okay try these next steps:

 

1. Create the Sales DAX seperatley: Sales = SUM(Sales[Sales])

 

2. Create your LY Sales measure: LY Sales = CALCULATE([Sales], SAMEPERIODLASTYEAR(Sales[txn_dte].[Date]) )

Hi, here is what i get when i select the year 2019 and 2020, 2019 LY sales show nothing.

Thanks

 

 

image.png

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors