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
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
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.