Forum Discussion
Merge measures into column for filtering data
Hi guys! Can anyone answer a question about power bi?
I have a table with a date column. I need to solve a problem as follows:
1- A filter must be created to select the date.
2- The dashboard should filter the table with the value of that date and with the value of the previous day.
- In other words:
- If the user has selected the day 30-08-2024, it should show the data referring to the day 30-08-2024 and 29-08-2024
This column with the two dates will be used to filter another table based on the data collected.
I don't know how to do this, so if someone could help, that would be great!
Translated with DeepL.com (free version)
Hey gpuc09_ ,
No worries! I’ve put together a DAX measure that calculates and displays the values for both the selected date and the previous date. Take a look at the attached image and file to see how it works. Hope it helps!
3 Replies
- marcelsmaglhaesSuper User
Hey gpuc09_
To achieve this in Power BI, you can create a measure that dynamically selects both the chosen date and the previous day. See the example below. The approach uses the varselecteddate and pday (previous day's date)to adjust the data context accordingly - gpuc09_Regular Visitor
Hello @marcelsmaglhaes!
Thanks for your help, but it's not exactly what I wanted... Let me see if I can be more specific and send you a draft of the dashboard!
Suppose I have this data (Image 01), where I have several values for the dates from October 1st to October 10th. When I create a filter, with a single selection, of the dates present in my column (Image 02), I need the table to show the values of that selected date and the previous day, in separate rows (Image 03).
I think it's clearer this way! If you can edit the draft to get the result, that would be great!
Thank you very much!
Dataset values:data,value2024-10-01,2132024-10-02,2452024-10-02,1132024-10-02,1052024-10-03,3182024-10-03,1872024-10-04,3732024-10-04,3252024-10-04,1882024-10-05,2612024-10-05,1222024-10-05,3572024-10-06,3632024-10-07,3802024-10-08,1502024-10-08,4202024-10-09,3912024-10-10,380- marcelsmaglhaesSuper User
Hey gpuc09_ ,
No worries! I’ve put together a DAX measure that calculates and displays the values for both the selected date and the previous date. Take a look at the attached image and file to see how it works. Hope it helps!