Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Dynamic legend for future and past date

Hi there,

I have a line chart with x-axis date and y-axis sales value. I wnated to put a legend which shows the last two months, current month and future two months (for example Nov, Dec, Jan, Feb and March). The current month in this case will be January. I tried the relative date but it only gives me the last or the future date, but I want both. Any help will appreciate.

Thanks

1 Reply

  • Hey Anonymous !

     

    I think for you to achieve this, you will need to write a DAX to check the current year and current month, check if the current month is January, because if so, you will need to go back a year to pick up the last two months. After the checks, you will "tell" your measure to filter your dimension table only to calculate the value between two months and year passed and two months and year futures. Something like that. I'm not on the computer right now to write the DAX, so I'm sorry about that.