Forum Discussion

srk_powerbi's avatar
srk_powerbi
Helper II
5 years ago
Solved

help..calculate Previous year total based on custom dates

hi,  I have a date table and sales table like below. I need to calculate Previous Yr total based on dates selected. Ex : date slicer will be based on 'This Yr date' column,  and if i select 5/15/20...
  • Jihwan_Kim's avatar
    Jihwan_Kim
    5 years ago

    Hi, srk_powerbi 

    Thank you for your feedback.

    I am not quite sure how your whole data model looks like. But by only seeing this sample, I think one of many ways to achieve this is to create an inactive relation ship with 'Date Table'[previous Yr Fiscal Date] and 'sales table'[date] like the below.

    Please check the link down below.

     

     

    Sales Previous Yr Fiscal Date =
    CALCULATE (
    SUM ( 'sales table'[sales] ),
    USERELATIONSHIP ( 'Date Table'[Previous Yr Fiscal date], 'sales table'[date] )
    )
     
     
     

    Hi, My name is Jihwan Kim.


    If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


    Linkedin: linkedin.com/in/jihwankim1975/

    Twitter: twitter.com/Jihwan_JHKIM