Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I have a dataset that has multiple different date calculations on the same row.
Date1,2,3,etc. There are 12 separate date differential calculations between about 6-8 different date columns on the same row.
Is there a way to calculate all of those separate calculations then wrap into a slicer? I tried unpivoting but this will only display the actual date and not the calculation. I have it running properly another way but everything is on separate tabs. I included an example of what I am trying to do as I am probably not detailing it very well.
Solved! Go to Solution.
Here is a DAX version of @ahadkarimi 's answer. (The power query version is way easier for larger datasets.)
categoryTable =
var _t1 =
SELECTCOLUMNS(
surveyTable,
"_survey", [Survey],
"_category", "cat1",
"_value", DATEDIFF([Date1], [Date2], DAY)
)
var _t2 =
SELECTCOLUMNS(
surveyTable,
"_survey", [Survey],
"_category2", "cat2",
"_value", DATEDIFF([Date1], [Date3], DAY)
)
var _t3 =
SELECTCOLUMNS(
surveyTable,
"_survey", [Survey],
"_category3", "cat3",
"_value", DATEDIFF([Date2], [Date4], DAY)
)
Return
UNION(_t1, _t2, _t3)
Proud to be a Super User! | |
I want to try the first solution because that will clean up some of the calculations. Will get back today with response. Thanks for your help.
Here is a DAX version of @ahadkarimi 's answer. (The power query version is way easier for larger datasets.)
categoryTable =
var _t1 =
SELECTCOLUMNS(
surveyTable,
"_survey", [Survey],
"_category", "cat1",
"_value", DATEDIFF([Date1], [Date2], DAY)
)
var _t2 =
SELECTCOLUMNS(
surveyTable,
"_survey", [Survey],
"_category2", "cat2",
"_value", DATEDIFF([Date1], [Date3], DAY)
)
var _t3 =
SELECTCOLUMNS(
surveyTable,
"_survey", [Survey],
"_category3", "cat3",
"_value", DATEDIFF([Date2], [Date4], DAY)
)
Return
UNION(_t1, _t2, _t3)
Proud to be a Super User! | |
Hi @common763,
Create Calculated Columns for each date difference (e.g., Date1 - Date2, Date1 - Date3, etc.).
Unpivot the Calculated Columns in Power Query to create a long format table.
Use the unpivoted column names as your slicer/filter.
So you can select different date calculations in a slicer.
Did I answer your question? If so, please mark my post as the solution!✔️
Your Kudos are much appreciated! Proud to be a Responsive Resident!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |