Forum Discussion

michelangelo_fi's avatar
michelangelo_fi
New Member
8 years ago
Solved

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: 

 

 

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

 

Thank you for yours reply!!!

 

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

  • 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

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

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

  • alexei7's avatar
    alexei7
    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