Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello,
I am trying to determine start and end dates of a range that act as a "gap" between when a room is occupied. So, a room would be occupied from a start to an end date. However, after the end date comes and goes, there is now a gap between when that room was and will be occupied. Here's what it looks like in Excel. My end result is that I want the start and end dates for the gap so that it can then be mapped in a Gantt Chart:
The Gap Start begins one day after the End date and the Gap End date ends one day prior to the next occupation of that room.
Thank you for your help!
@Bifinity_75 @v-rongtiep-msft Thank you for your responses. After diving deeper into my data, it turns out there are some other factors to consider. Initially, I wasn't aware that a room could be occupied by more than one item at a time so some of the calculations based on "EARLIER" or utilzing the Index column in Power Query were resulting in some incorrect dates. Here's a better indication of what I'm working with:
As you can see, some of the blue bars overlap and they are in the same room at the same time. The green highlights are the gaps in the rooms for this time period that I'd like to be able to show. The point of all of this is for an individual to be able to look at a Gantt chart and say "OK, this room is available from this date to this date".
Another consideration:
- A gap of only one day is irrelevant so it would not need to show up on the Gantt
Hopefully this helps and I really do appreciate your effort here!
Regards
Hi @JLambs20, is the "name" of the step to insert the index column:
Usually the name is 'Addex Index', but if you have another language, the name will be different. If you change it, it should work for you.
Best regards
Hi @JLambs20 ,
I have created a simple smaple, please refer to it to see if it helps you.
Add an index column in the Power Query.
Then add two custom columns.
=Date.AddDays([End], 1)
=try Date.AddDays(Table.SelectRows(#"Added Custom",(x)=>x[Index]=[Index]+1)[start]{0},-1) otherwise ""
I have also create columns use dax.
gap end = var _next=CALCULATE(MAX('Table'[start]),FILTER('Table','Table'[Index]=EARLIER('Table'[Index])+1))
return
IF(_next=BLANK(),BLANK(),_next-1)
gap start = 'Table'[End]+1
If I have misunderstood your meaning, please provide more details with your desired output and pbix file without privacy information.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @JLambs20 , try this:
1º.- in Power Query, create a Index Column:
2º.- Create a custom column (Name: Gap Start) with this function:
Date.AddDays([End],1)
3º.- Create a custom column (Name: End start) with this function:
try Date.AddDays(#'Added Index' [Start] {[Index]+1},-1) otherwise ""
4º- The result:
Best regards
Thanks for the feedback! I'm having one issue with that last equation you wrote. The sytax for #'Added Index' doesn't seem to work. It's saying there should be a token literal in there somewhere. What am I missing?
Hello,
I have seen a solution to this before at the below link:
Just make sure you note there are two parts to the answer in different replies. The first requires you to use M Code to make a partition index by room number.
Then the second creates two calculated columns, one for previous date end, and one for the date diff.
Good luck
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
65 |
User | Count |
---|---|
135 | |
118 | |
101 | |
71 | |
61 |