cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
UserPBI
Frequent Visitor

Creating list of dates per user based on Start/End date

Hello all!

 

I'm having issues while creating a new column(or a list), that would allow me to see which person would be unavailable at a specific date. I have a list(table) with person name, start and end date which X person would be on Holiday(for instance). I think that If I could create a column that would give me a row for each day in between those two dates that someone will be unavailable, I would be able to create all kind of reports on top of this information.

What would be the best option in this case and how can I achieve this? I've been trying to use DATESBETWEEN and DATESINPERIOD dax formulas to get this information, but I couldn't make this work. 

 

UserPBI_1-1619621344534.png

 

Thank you!

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @UserPBI ,

Based on your description, seems like you want to expand rows based on the two date columns.

You can try this query in power query editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUfIsqsxLBNIe+TmZKYmVQJaRgZGhvqG+CYJpoRSrE63kBBTwKs3JTCRGfSwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Alias = _t, Title = _t, Category = _t, EventDate = _t, EndDate = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Alias", type text}, {"Title", type text}, {"Category", type text}, {"EventDate", type date}, {"EndDate", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Date", each {Number.From([EventDate])..Number.From([EndDate])}),
    #"Expanded Date" = Table.ExpandListColumn(#"Added Custom", "Date"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Date",{{"Date", type date}})
in
    #"Changed Type1"

date.png

Attached a sample file in the below, hopes it could help.

 

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

View solution in original post

3 REPLIES 3
UserPBI
Frequent Visitor

Thank you all for both of your suggestions! Both will be useful in the future for sure.

v-yingjl
Community Support
Community Support

Hi @UserPBI ,

Based on your description, seems like you want to expand rows based on the two date columns.

You can try this query in power query editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUfIsqsxLBNIe+TmZKYmVQJaRgZGhvqG+CYJpoRSrE63kBBTwKs3JTCRGfSwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Alias = _t, Title = _t, Category = _t, EventDate = _t, EndDate = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Alias", type text}, {"Title", type text}, {"Category", type text}, {"EventDate", type date}, {"EndDate", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Date", each {Number.From([EventDate])..Number.From([EndDate])}),
    #"Expanded Date" = Table.ExpandListColumn(#"Added Custom", "Date"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Date",{{"Date", type date}})
in
    #"Changed Type1"

date.png

Attached a sample file in the below, hopes it could help.

 

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

View solution in original post

Jihwan_Kim
Super User
Super User

Hi, @UserPBI 

Please check the below picture and the sample pbix file's link down below, whether it is what you are looking for.

All measures are in the sample pbix file.

Picture1.png

 

How many people =
CALCULATE (
COUNTROWS ( Data ),
FILTER (
Data,
Data[StartDate] <= MAX ( 'Calendar'[Date] )
&& Data[EndDate] >= MIN ( 'Calendar'[Date] )
)
)
 
 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!