Forum Discussion
Creating side-by-side view of table data given two dates
Hello!
Given a table like this
| valid_from | valid_to | article | price |
| 2022-01-05 | 2022-01-15 | A | 200 |
| 2022-01-16 | 2022-03-17 | A | 300 |
| 2022-03-18 | A | 350 | |
| 2022-01-08 | 2022-01-15 | B | 30 |
| 2022-01-16 | 2022-03-23 | B | 40 |
| 2022-03-14 | B | 35 |
I want to create a visualization which let's the user select two dates t_1 and t_2 and display the active prices next to each other. So for example if the user select t_1 = '2022-02-01' and t_2 = '2022-04-01' then the resulting table should be displayed:
| article | t1_valid_from | t1_valid_to | t1_price | t2_valid_from | t2_valid_to | t2_price |
| A | 2022-01-16 | 2022-03-17 | 300 | 2022-03-18 | 350 | |
| B | 2022-01-16 | 2022-03-23 | 40 | 2022-03-14 | 35 |
I've played around with this problem in PowerBI and the closest I've gotten is creating two slicers (one of type above and one of type below) and then classifying rows in the original table as either being irrelevant, matching t1 or matching t2. But that's about it. Does anyone know any other way in which I should approach this problem?
4 Replies
- lbendlin
Super User
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523- smanFrequent Visitor
I've updated the post - thanks for feedback.
- lbendlin
Super User
Your approach should work. However I would be concerned that the layout may be confusing to your users. What is the relationship between these two date slicers? What if the user picks and earlier date for T2 and a later date for T1?
A timeline chart may be a better answer.