Forum Discussion
Need help on dynamic interactions
Hi,
I have a table visual which has a timestamp column and a line chart with same timestamp column in X axis.
Now when I/end user click on any time stamp value I need the line chart to display last 5 days and next 5 days values and dynamicaly changes based on selected timestamp value.
I tried created two measures as last5Day = selectedvalue('table'[timestamp]) - 5 and next5Day = selectedvalue('table'[timestamp]) + 5, now I tried adding these two measures in minimum and maximum X axis vales in visualization pane, but it is not working.
If any leads please let me know. Thanks in Advance
8 Replies
- Selva-Salimi
Solution Sage
Hi Anonymous
you should use a measure to calculate the Y-axis value. you can write the measure as follows : (lets assume thatyou have sales data)
measure sales_in range := calcualte (sum(sales) , filter (all(table) , timestamp>= selectedvalue(timestamp) - 5 && timestamp<= selectedvalue(timestamp) + 5)
If this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
Hi Thank you for your solution, Unfortunately it is not working :(.
- AnonymousNot applicable
when I select only one timestamp due to interaction it is filtering to only one point in line chart, if I block interaction it is not working
- DataNinja777
Super User
Hi Anonymous ,
You can create a measure that dynamically calculates whether a timestamp falls within the 5-day range before or after the selected timestamp.
WithinRange = VAR SelectedDate = SELECTEDVALUE('table'[timestamp]) VAR StartDate = SelectedDate - 5 VAR EndDate = SelectedDate + 5 RETURN IF( 'table'[timestamp] >= StartDate && 'table'[timestamp] <= EndDate, 1, 0 )Next, in the line chart, add this WithinRange measure to the visual-level filter. Set the filter condition to show values where WithinRange = 1.
Then, set up interaction between the table and the line chart by using the Visual Interactions tool in Power BI. This will ensure that when a user clicks on a timestamp in the table, it dynamically updates the line chart.
Calculated columns would result in static values, whereas using a measure provides dynamic filtering that updates the line chart based on user interactions. This is why using a measure is preferred for this task.
- AnonymousNot applicable
sorry, this is not working, when I set up interaction between the table and the line chart by using the Visual Interactions tool in Power BI the line chart is filtered to one value, this is because my X axis is timestamp