Forum Discussion
I calculate in hours between two different record dates
Good morning community, I would need the following help.
Currently I have different order numbers and in the factory they would need to know the difference in hours between the end of one order and the beginning of the next. I have created a simplicated table to give you an idea:
The time of the first order is white since we do not have a previous order to be able to do the calculation.
This would be the calculation to make:
Current Order Number D420019A = End Date of Previous Order D433953AC - Current Order Start Date D420019A
Current order number D420019C= End date of previous order D420019A- Start date of current order D420019C
Thank you very much for your help
22 Replies
- Syndicate_Admin
Administrator
First of all apologize for not having responded before but last week I was involved and did not have time to try the code you had sent me.
First of all, thank you very much for the help, try the code and perfect.
As for the debug, from what I see here you can't make a console.log and see what the variable is worth at that time or put a breakpoint and ask for the value of a specific variable, right?
Anyway, again thank you very much.
- tamerj1
Community Champion
Hi Admin Syndicate_Admin
thank you for your follow up.
RWRWYou can export you model to excel for furthe debugging. But I guess you should have some kind of power bi product license.
- Syndicate_Admin
Administrator
Hello again
I have a doubt.
After I have finished I have been asked to add a filter to the report in which the user can select a date range.
Assuming there are 3 records like this table that I previously attached to you:
If the user selects from 1/3/2022 to 1/6/2022 he should give me a single record (Last record of the table) and in the empty time calculation since it is the only record returned.
When I make the selection, visually on the screen I only see a record but with the time calculation of 9.14 in the time field since although visually we do not see it the dataset still has loaded all the records. Would there be any way to refresh the dataset when the date selection is made?
I hope I have explained thanks
Best regards
- tamerj1
Community Champion
Hi Syndicate_Admin
Here is a sample file with the solution https://www.dropbox.com/t/xt1mFlBtHgSNF5UrTime = VAR CurrentStart= Orders[Start Date] VAR PreviousEnd = MAXX ( FILTER ( Orders, Orders[End Date] < CurrentStart ), Orders[End Date] ) VAR TimeDifference = DATEDIFF ( PreviousEnd, CurrentStart, MINUTE ) RETURN IF ( NOT ISBLANK ( PreviousEnd ), DIVIDE ( TimeDifference, 60 ) )- Syndicate_Admin
Administrator
I am new to all this and I would like to know if there is any way to see what gives you back the functions or the value of the variables?
I mean if you can put interruption points or make a display of the values that are assuming the values.
Thank you so much
- tamerj1
Community Champion
Syndicate_Admin
Not sure if I accurately understand his question but I think the following might be the answer he is looking for