Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
In my table, I have Start_Date and EndDate. I want to expand the dates in between.
Let's say:
ID Start_date End_Date
1 2018/01/01 2018/01/03
I want this:
ID Date
1 2018/01/01
1 2018/01/02
1 2018/01/03
I tried to use this DAX function (Add column feature in dashboard):
DATESINPERIOD( DimDate[FullDate],[START_DATE],[NUM_DAYS],DAY)
But, it gave me this error:
A table of multiple values was supplied where a single value was expected.
Well, I have a table named DimDate and NUM_DAYS is the number of days between start and end date.
Thanks!
Solved! Go to Solution.
Hi @pouryas7
To create this table using DAX, you would have to click New Table rather than New Column.
Adding a column can only add a column using a scalar expression, preserving the number of rows.
To create this expanded table, you would need to create a table with an expression like this (assuming DimDate contains all required dates):
Expanded Table = SELECTCOLUMNS ( GENERATE ( ExistingTable, DATESBETWEEN ( DimDate[FullDate], ExistingTable[Start_date], ExistingTable[End_Date] ) ), "ID", ExistingTable[ID], "Date", DimDate[FullDate] )
Alternatively, you could use the CALENDAR function to generate the sequences of dates without relying on DimDate:
Expanded Table = SELECTCOLUMNS ( GENERATE ( ExistingTable, CALENDAR ( ExistingTable[Start_date], ExistingTable[End_Date] ) ), "ID", ExistingTable[ID], "Date", [Date] )
Regards,
Owen
Hi @pouryas7
To create this table using DAX, you would have to click New Table rather than New Column.
Adding a column can only add a column using a scalar expression, preserving the number of rows.
To create this expanded table, you would need to create a table with an expression like this (assuming DimDate contains all required dates):
Expanded Table = SELECTCOLUMNS ( GENERATE ( ExistingTable, DATESBETWEEN ( DimDate[FullDate], ExistingTable[Start_date], ExistingTable[End_Date] ) ), "ID", ExistingTable[ID], "Date", DimDate[FullDate] )
Alternatively, you could use the CALENDAR function to generate the sequences of dates without relying on DimDate:
Expanded Table = SELECTCOLUMNS ( GENERATE ( ExistingTable, CALENDAR ( ExistingTable[Start_date], ExistingTable[End_Date] ) ), "ID", ExistingTable[ID], "Date", [Date] )
Regards,
Owen
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
99 | |
76 | |
64 | |
58 |
User | Count |
---|---|
148 | |
113 | |
97 | |
84 | |
67 |