Find Next and Latest Date, With Conditions - excel

I have a list of asset IDs and service dates. I'd like to find the last service date and the next service date for a specific asset (each in their own column, with each row corresponding to an asset ID). The way I tried it was to use a formula like this:
{=IF(MIN(IF(Lists!$J$11:$J$31 = 'Action Overview'!A2,Lists!$K$11:$K$31))=0,NA(), MIN(IF(Lists!$J$11:$J$31 = 'Action Overview'!A2,Lists!$K$11:$K$31)))}
This would be to find the last service date, and I'd use 'MAX' in place of 'MIN' for the next service date. The problem is that my list contains dates before the last service date and after the next service date, so I wind up with dates far in the past and far into the future. I think the way to fix this would to be to use =TODAY() to get the current date, and use logic that says "maximum date for this asset less than or equal to current date" for the last service date and "minimum date for this asset greater than or equal to current date". I just don't have the familiarity with Excel's functions to make this work.
Any help you can provide with this would be greatly appreciated.
Thanks,
Dan

I managed to find a solution myself. Here's what it came out to be for the last day in for service:
{=MAX(IF(Table4[Asset]='Action Overview'!A2,IF(Table4[In Shop]<=TODAY(),Table4[In Shop])))}
And here's what it was for next service date:
{=MIN(IF(Table4[Asset]=A2,IF(Table4[In Shop]>=TODAY(),Table4[In Shop])))}
Table4 is just the table I have the schedule set up in. You'd just select the range you have your values in if you weren't using a table.

Related

Excel get the difference in date by month for a sorted group of ids

Using the example below I can sort the list by Id to group them but i am having a hard time writing a formula that will give me the difference in date by month for each group of Id
Date ID
5/13/2022 IC12
3/18/2022 IC12
9/17/2021 IC13
7/16/2021 IC13
formulas I have tried
DATEDIF(MAXIFS(B2:B10,A2:A10,"IC12"),MINIFS(B2:B10,A2:A10,"IC12"),"m"))
but it does not seem to be work
now for me to get the first group of Id correct i used the formula
=(TODAY()-(IF([#[ID]]="IC12",MIN(A2:A3))))/(365/12)
which gives me what I want but I cannot use it for the rest of the data set which is almost 100k lines due to having different group of Id
5/13/2022 IC12 10.03
3/18/2022 IC12 10.03
You can use MINIFS to check against the ID of the current row:
=(TODAY()-MINIFS([Date],[ID],[#ID]))/(365/12)
UPDATE according to comments:
=(MAXIFS([Date],[ID],[#ID]) - MINIFS([Date],[ID],[#ID]))/(365/12)

Excel Power Pivot: Match next non-blank item after date match for customer across two tables using DAX

I need to create a calculated column in Table_Order that would find the next matching, non-blank Customer Status on or after the current Order Date for the current row Customer #.
The tricky part is when there is no matching Customer Status in Table_Ship for a Customer # on a particular Order Date (please see the orange highlights). The match then needs to be on the next matching Ship Date for the Customer # where the Customer Status is not blank.
Please could somebody help me and show me the DAX?
I've spent a long time Googling and have gotten nowhere. I feel like this should be easy!
Also please bear in mind that these tables are massively simplified versions of my actual work, and any suggestion to reorganise the tables or start from scratch won't help me, I need some DAX please!
Thanks in advance!
Phil.
I understand that you have large datasets, but I would recommend you create a FactCustomer table. Here there are the steps I followed with the data you provided.
Create a FactCustomer table
FactCustomer =
DISTINCT ( Table_Ship[Customer #] )
Create a relationship between Table_Ship and FactCustomer and Table_Order and FactCustomer, using Customer # as key.
Create a calculation in Table_Order to find customer status. The calculation makes a lookup (similar to VLOOKUP in excel) to find customer with the same date. This would retrieve the blank for Customer #3, so is neccesary to create a second calculation that would scan Table_Ship for the minimum date without blanks. The final step is using an IF statement to treat blank in the first function, when they are blank, the second formula is used.
Customer Status =
var find_customer = LOOKUPVALUE(Table_Ship[Customer Status],Table_Ship[Ship_Date],[Order Date],Table_Ship[Customer #],[Customer #])
var last_non_blank_date = CALCULATE(min(Table_Ship[Ship_Date]),Table_Ship[Customer Status]<>BLANK())
var find_non_blank = CALCULATE(min(Table_Ship[Customer Status]),filter(Table_Ship,Table_Ship[Ship_Date]=last_non_blank_date))
return if(ISBLANK(find_customer),find_non_blank,find_customer)
The result I get:

Fetching date value from a SharePoint-list, to use in date&time specific field in flow

I'm trying to design a Microsoft Flow, which will create a outlook calendar event entry based on information in a SharePoint-online list.
The list will contain a value for a DueDate its a column of type Date, not including time.
I want to be able to create a outlook calendar entry on the date based off the duedate column. The calendar entry form in flow allows via dynamic content to add dates that also include time, however date columns not containing time cannot be added that way.
Is there a workaround to this, some expression that would allow me to fetch values from columns more freely and then possible append a time to it
I have tried converting the column in sharepoint to a Date with Time column and that workaround worked, however its not what I'm looking for. Id like to know how to be able to work around this because I don't necessarily want my column as a date-time column which can cause problems later on.
I have tried this expression:
formatDateTime(concat(item()?['DATE'], '08:00')'yyyy-MM-ddThh:mm:ss')
But I know this is wrong and it doesn't work. I'm simply not sure how to do it.
https://puu.sh/Df5ni/05cb882b23.png
I want the flow to add a calendar entry based off the due date column which i can append my own time to like the start of the day and last til the afternoon.
Actual results are I don't seem to be able to use a date column, just a date-time column for start and end times of the event, date column without time doesnt appear in the dynamic content list.
If there is some way to manually fetch values instead of using the dynamic content that is very powerful and can then possibly be converted to the right format using additional code.
Date column name in my list is date_without_time of type Date (Add time set to NO):
New element:
Function used in Create event (V2) action:
formatDateTime(triggerBody()?['date_without_time'],'yyyy-MM-ddT09:35')
Result:
Calendar:

Excel Help - using IF and WORKDAY functions to generate a due date

I am trying to forumlate an IF statement that will generate a due date by taking a given date and adding business days to that dependent on a value in a separate column.
I started off with:
=IF(E3="Fatal",D3+1,IF(E3="Life Threatening",D3+1,IF(E3="Non-Fatal",D3+3,IF(E2="Non-Life Threatening",D3+3,IF(E3="Non-Susar",D3+5,"")))))
But this does not use the WORKDAY or WORKDAY.INT functions at all and is something I am now needing to add. I have collated a list of bank holidays to add into the new function these are listed - 'Backend Sheet (No Edit)'!C1:C752
Example of the sheet is below, I basically need to have it add 1,3,5 business days to the "query received date" dependent on the value in the "seriousness" column and print the new date into the "first attempt due by date" column
Appreciate any help that can be given!
Put your seriousness in a separate helper table along with the days adjustment. Then use workday to find your attempt date.
=workday([date received], index([helper table adjustment],match([this table seriousness],[helper table seriousness],0)),'Backend Sheet (No Edit)'!C1:C752)

Issue with date and time value - Lists in Sharepoint

Is there a way to make "date and time" column in SharePoint so it will behave in this way:
-if date that is entered in that column is today, tomorrow that column will be empty.
To explain it a lil' bit better, lets put it this way:
That column is reservation column. User enters the date on which he will stop doing something:
column_1-column_2-column_3-RESERVATION_COLUMN
If today is 01.01.2012, and I will be doing something till 05.01.2012., I will enter "05.01.2012." in RESERVATION_COLUMN". When that day comes, or the day after it (isn't really mather) that column will be empty.
I tried some ways, but I didn't succeed. Any help?
Thanks in advance,
K.
Only way I can think of is using a workflow.
Using workflow -> Wait till day + 1 then Set field value to blank.
also you can create TimerJob, which will be executed one or few times per day.
This timer job will query list items with your parameters, like items, where in the date field is value equals today or less then today. Then TimerJob will iterate and update this field.
Other, more difficult way is to write your own custom datatime field with specific behavior.

Resources