Forum Discussion
Time representation with DATEDIFF
- 5 years ago
With this you get all dates required ?
Tables des Dates Intervalles = VAR DateDebut=MIN('TF GRA 700 (2)'[Date de début]) VAR DateFin=MAX('TF GRA 700 (2)'[Date de début]) VAR TabDates=SELECTCOLUMNS(CALCULATETABLE(Dates, DATESBETWEEN(Dates[Date],DateDebut,DateFin)), "Dates TF",Dates[Date]) RETURN TabDatesThen you need to add column(s), but depends on what you want.
If you want the total hours per day or make difference by machine...Next step could be something inspired by that :
Tables des Dates Intervalles = VAR DateDebut=MIN('TF GRA 700 (2)'[Date de début]) VAR DateFin=MAX('TF GRA 700 (2)'[Date de début]) VAR TabDates=SELECTCOLUMNS(CALCULATETABLE(Dates, DATESBETWEEN(Dates[Date],DateDebut,DateFin)), "Dates TF",Dates[Date]) VAR TabDates2=CROSSJOIN(TabDates,'TF GRA 700 (2)') VAR TabDates3=ADDCOLUMNS(TabDates2,"Valeur",IF([Dates TF]>='TF GRA 700 (2)'[Date de début]&&[Dates TF]<='TF GRA 700 (2)'[Date de fin],1,0)) RETURN FILTER(TabDates3,[Valeur]=1)This could be done with less lines but at least it is step by step.
You should have a table with that with all dates and a column to select only dates you are interested in.
Hope this helps
With this you get all dates required ?
Tables des Dates Intervalles =
VAR DateDebut=MIN('TF GRA 700 (2)'[Date de début])
VAR DateFin=MAX('TF GRA 700 (2)'[Date de début])
VAR TabDates=SELECTCOLUMNS(CALCULATETABLE(Dates,
DATESBETWEEN(Dates[Date],DateDebut,DateFin)),
"Dates TF",Dates[Date])
RETURN TabDates
Then you need to add column(s), but depends on what you want.
If you want the total hours per day or make difference by machine...
Next step could be something inspired by that :
Tables des Dates Intervalles =
VAR DateDebut=MIN('TF GRA 700 (2)'[Date de début])
VAR DateFin=MAX('TF GRA 700 (2)'[Date de début])
VAR TabDates=SELECTCOLUMNS(CALCULATETABLE(Dates,
DATESBETWEEN(Dates[Date],DateDebut,DateFin)),
"Dates TF",Dates[Date])
VAR TabDates2=CROSSJOIN(TabDates,'TF GRA 700 (2)')
VAR TabDates3=ADDCOLUMNS(TabDates2,"Valeur",IF([Dates TF]>='TF GRA 700 (2)'[Date de début]&&[Dates TF]<='TF GRA 700 (2)'[Date de fin],1,0))
RETURN FILTER(TabDates3,[Valeur]=1)This could be done with less lines but at least it is step by step.
You should have a table with that with all dates and a column to select only dates you are interested in.
Hope this helps
You, mister, are a freaking genius 😍
I used your technique and I "just" had to find the right switch function that respect every "time bounderies"
If someone needs it :
TFonctionnement = SWITCH(TRUE(),
'Tables des Dates Intervalles'[Dates TF]='Tables des Dates Intervalles'[Date de début] && 'Tables des Dates Intervalles'[Dates TF] = 'Tables des Dates Intervalles'[Date de fin], 'Tables des Dates Intervalles'[Jour passé],
'Tables des Dates Intervalles'[Dates TF]<'Tables des Dates Intervalles'[Date de fin] && 'Tables des Dates Intervalles'[Dates TF]>'Tables des Dates Intervalles'[Date de début],TIME(23,59,59),
'Tables des Dates Intervalles'[Dates TF]='Tables des Dates Intervalles'[Date de début],TIME(23,59,59)-'Tables des Dates Intervalles'[Heure de début],
'Tables des Dates Intervalles'[Heure de fin])
I now have a total of 23h59m59s per day, and I just have to filter on Marche or Arrêt to have the time in the state per day, like this (filtered on "Marche") :
Now, i'll work on how many state change per day etc.
A big thanks for your help huys, really appreciate it !