Forum Discussion
fleming507
8 years agoFrequent Visitor
Number of Days Value to Rows
I have a dataset that I need to maniuplate for year end reporting, but the data from source is not entirely suitable. For each service there is a Scheduled Start Date and Numbder of days scheduled. ...
- 8 years ago
Hi fleming507
Try this calculated table. Assuming your table name is Table1
Table = VAR Temp1 = GENERATE ( Table1, VAR mydays = CALCULATE ( VALUES ( Table1[ NumberOfDays] ), Table1[ServiceName] = EARLIER ( Table1[ServiceName] ) ) VAR adddays = ( INT ( mydays / 7 ) + 1 ) * 2 RETURN GENERATESERIES ( 1, mydays + adddays ) ) VAR temp2 = ADDCOLUMNS ( ADDCOLUMNS ( Temp1, "Scheduled Dates", [ScheduledStartDate ] + [Value] - 1 ), "WeekDay", WEEKDAY ( [Scheduled Dates], 2 ) ) VAR temp3 = FILTER ( temp2, [WeekDay] < 6 ) VAR temp4 = ADDCOLUMNS ( temp3, "RANK", RANKX ( FILTER ( temp3, [ServiceName] = EARLIER ( [ServiceName] ) ), [Scheduled Dates], , ASC, DENSE ) ) VAR temp5 = FILTER ( temp4, [RANK] <= [ NumberOfDays] ) RETURN SUMMARIZE ( temp5, [ServiceName], [Scheduled Dates] )
parry2k
Super User
8 years agoYou can also achieve this by power query, here is link to a post which describe how this can be done?
https://community.powerbi.com/t5/Desktop/Convert-date-ranges-into-list-of-dates/td-p/129418
https://community.powerbi.com/t5/Desktop/Get-a-list-of-dates-from-range-and-schedule/td-p/174811