Forum Discussion

shubhamc_002's avatar
shubhamc_002
Icon for Helper I rankHelper I
3 years ago
Solved

Get previous Time period data in calculated column | DAX

Hi Team,

We have 3 columns Date, Product, Amount in our table.  Our requirement is to calculate new column which should have amount of product last 1 year back and each row should have last one yaer of amount. We should not use Sameperiodlast year since time frame is not exactly 1 years back.

 

Date   Product    Amount    Previous Year amount

D1     P1           Val1                VAL300

D2     P1           Val2                VAL301

.       .

.       .

.       . 

.       .

.       .

D300  P1         Val300
D301  P1         VAL301

 

Thanks

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi shubhamc_002 ,

     

    Based on your description, please try:

    Previous Year amount = CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),'Table'[Product]=EARLIER('Table'[Product]) && 'Table'[Date] =EARLIER('Table'[Date])+299))

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi shubhamc_002 ,

     

    Based on your description, please try:

    Previous Year amount = CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),'Table'[Product]=EARLIER('Table'[Product]) && 'Table'[Date] =EARLIER('Table'[Date])+299))

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum