Forum Discussion

Fousek_Brousek's avatar
Fousek_Brousek
Frequent Visitor
2 years ago

Using Date value as a way to restrict date range in plot visual

Hello, 

 

I would like to ask for help since I am quite stuck. The thing I need sounds pretty simple: I have a table visual which have two columns: Date column with dates and Price columns with prices. I would like to be able to click on any date in the table (i.e. row) and use this date to set x axis (dates) on plot visual on the same report page (for example the plot will show time range of 3 days before the selected date).  The reason for this is that I need to analyze other values/variables (liek weather etc) in the days around the given date to see the context and cause of this event (the reason of high price).  

 

 

The data model is prety simple: Price table has columns Date/Time/Country/Price and then there is Time table and Date table.


I though that I would be able to restrict the plot date range by selectedvalue function but it is just not working. Something like this: 

Average Price =

VAR SelectedDate = SELECTEDVALUE(Dates[Date])

RETURN

CALCULATE(
    AVERAGE(Prices[Price of electricity]),
    Prices[Date] <= SelectedDate - 3 && Prices[Date] <= SelectedDate
    )
Thank you for any help.

3 Replies