Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Display Data for Last 3 months based on slicer selection

Hi,    I am having a dim table  - Months, having the below values (until Dec-20) which is connected to multiple fact tables (one to many relationships) using a Month column. In those fact tables th...
  • parry2k's avatar
    parry2k
    6 years ago

    Anonymous you have to use disconnected  table for this purpose, create a table for slicer and use value from that table to filter the data in your main table using TREATAS

     

    Measure = 
    VAR __dateRange = DATESINPERIOD ( DateDisconnected[Date], MAX( DateDisconnected[Date] ), -3, MONTH )
    RETURN
    CALCULATE ( SUM ( Table[Amount] ), TREATAS ( __dateRange, DateTable[Date] ) )

     

    I haven't tested this but it will get you started if you are unable to figure out, share sample pbix file and can take a look.

     

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.