Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Get help with timestamp

Hello,

In table1 i have a timestamp like 1-3-2022 20:25:35.

In table2 i have created a schedule with teamnumbers and the time the shift started and ended.

For example: 

Starttime                            Endtime                           Teamnumber

1-3-2022 14:00:00              1-3-2022 22:30:00           2

Wich dax formule or measure do i need to get the teamnumber (table2) in table 1 in a new column?

 

  • Hi Anonymous 

    If you want to create a column, try this,

    Teamnumber = CALCULATE(COUNTROWS(Table1),FILTER(ALL(Table1), Table1[timestamp]<=EARLIER(Table2[Endtime])&& Table1[timestamp]>=EARLIER(Table2[Starttime])))

    If you want to create a measure, try this,

    Measure = CALCULATE(COUNTROWS(Table1),FILTER(ALL(Table1), Table1[timestamp]<=MIN(Table2[Endtime])&& Table1[timestamp]>=MIN(Table2[Starttime])))

     

    Best Regards,

    Community Support Team _Tang

    If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Someone who knows the solution?

  • Anonymous , New column in table 1

     

    Team = maxx(filter(Table1, Table1[timestamp] >= table2[starttime] && Table1[timestamp] <= table2[endtime] ), Table2[teamnumber]) 

    • Anonymous's avatar
      Anonymous
      Not applicable

      The formule doesn't work...

  • v-xiaotang's avatar
    v-xiaotang
    Community Support

    Hi Anonymous 

    If you want to create a column, try this,

    Teamnumber = CALCULATE(COUNTROWS(Table1),FILTER(ALL(Table1), Table1[timestamp]<=EARLIER(Table2[Endtime])&& Table1[timestamp]>=EARLIER(Table2[Starttime])))

    If you want to create a measure, try this,

    Measure = CALCULATE(COUNTROWS(Table1),FILTER(ALL(Table1), Table1[timestamp]<=MIN(Table2[Endtime])&& Table1[timestamp]>=MIN(Table2[Starttime])))

     

    Best Regards,

    Community Support Team _Tang

    If this post helps, please consider Accept it as the solution to help the other members find it more quickly.