Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Eli_
Frequent Visitor

How to Transform table with Start Date and End Date with Status for specific date status

I would like to convert my table
From 3 columns(Start Date, End Date and Stautus)
To 2 columns (Date(all dates included in start and end), Status)

so I can know what the status is for specific, days, month or year.

 

thsi is what the table currently looks like.

Capture1.PNG

 

I just cant think of the best way posible to handle this..Every advise would be helpful

 

Idealy, I would imagine that just having a single date column and status would be the way to go, but not sure how to.

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello @Eli_ 

 

check out this solution. It creates in a custom column a list with all dates. However, don't know how the first row should be treated.

let
	Source = #table
	(
		{"dStart","dEnd","STATUS"},
		{
			{"43844","43848","Occupied"},	{"43753","43766","Vacant"},	{"43831","43832","Occupied"}
		}
	),
	ToDate = Table.TransformColumns
	(
		Source,
		{
			{
				"dStart",
				each Date.From(Number.From(_)),
				type date
			},
			{
				"dEnd",
				each Date.From(Number.From(_)),
				type date
			}
		}
	),
	AddDates = Table.AddColumn
	(
		ToDate,
		"Dates",
		each List.Dates(_[dStart], Duration.TotalDays(_[dEnd]- _[dStart])+1,#duration(1,0,0,0))
	),
    Expand = Table.ExpandListColumn(AddDates, "Dates"),
    ChangeType = Table.TransformColumnTypes(Expand,{{"Dates", type date}})
in
	ChangeType

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works. If this solution fits your need, copy and past a part of it and implement it in your query.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @Eli_ 

Select "start date" and "end date" columns, Unpivot columns.

After that, you can Add column->Date, add year, month, day columns.

Capture1.JPG

Best Regards

Maggie

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Jimmy801
Community Champion
Community Champion

Hello @Eli_ 

 

check out this solution. It creates in a custom column a list with all dates. However, don't know how the first row should be treated.

let
	Source = #table
	(
		{"dStart","dEnd","STATUS"},
		{
			{"43844","43848","Occupied"},	{"43753","43766","Vacant"},	{"43831","43832","Occupied"}
		}
	),
	ToDate = Table.TransformColumns
	(
		Source,
		{
			{
				"dStart",
				each Date.From(Number.From(_)),
				type date
			},
			{
				"dEnd",
				each Date.From(Number.From(_)),
				type date
			}
		}
	),
	AddDates = Table.AddColumn
	(
		ToDate,
		"Dates",
		each List.Dates(_[dStart], Duration.TotalDays(_[dEnd]- _[dStart])+1,#duration(1,0,0,0))
	),
    Expand = Table.ExpandListColumn(AddDates, "Dates"),
    ChangeType = Table.TransformColumnTypes(Expand,{{"Dates", type date}})
in
	ChangeType

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works. If this solution fits your need, copy and past a part of it and implement it in your query.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.