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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
michelangelo_fi
New Member

Sameperiodlastyear function don't work

Hi,

i have a simple table called TMP with 3 columns {DATE, PRODUCT, QUANTITY} and i try to obtain the total quantity of the previous year.

So i use SAMEPERIODLASTYEAR() function in this manner: 

 

TOTAL QUANTITY LY = CALCULATE([TOTAL QUANTITY];SAMEPERIODLASTYEAR(TMP[DATE]) )

 

The measure TOTAL QUANTITY is : 

TOTAL QUANTITY = sum(TMP[QUANTITY])

 

But when i check the results i get this: 

 

pbi.PNG

 

As you can see the column TOTAL QUANTITY LY is blank .....what's wrong?

 

Thank you for yours reply!!!

 

2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

Generally, for the time intelligence stuff to work you need a separate Calendar table that is related to your fact table.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

alexei7
Continued Contributor
Continued Contributor

Hi,

 

I think you need to have a separate "date" table for this to work, and join it in the model view to your TMP table.

 

Then in your Power BI visual, you bring in year/anno from the date table, and the Total Quantity and Total Quantity LY fields.

 

I did this and it worked for me.

 

Alexei

View solution in original post

4 REPLIES 4
alexei7
Continued Contributor
Continued Contributor

Hi,

 

I think you need to have a separate "date" table for this to work, and join it in the model view to your TMP table.

 

Then in your Power BI visual, you bring in year/anno from the date table, and the Total Quantity and Total Quantity LY fields.

 

I did this and it worked for me.

 

Alexei

thanks ! good job!

Greg_Deckler
Community Champion
Community Champion

Generally, for the time intelligence stuff to work you need a separate Calendar table that is related to your fact table.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

thanks a lot Greg! now it works!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.