Forum Discussion

PBISändy's avatar
PBISändy
Frequent Visitor
8 years ago
Solved

Find minimum timestamp within one day with DAX

Hi PBI Community,   i have the following problem and i really don't know how to solve it: I have for example a following table with processes:   process start end 1 22.01.2018 23:00 22...
  • v-jianhe-msft's avatar
    v-jianhe-msft
    8 years ago

    Hi,

     

    >>> For each specific day f.e. the 22.01 what was the minimum start timestamp on that day and what was the max end timestamp for one day?

    To accomplish this, you could split the column “start” into “startdate” and “starttime”, similarly, split “end” into “enddate” and “endtime”. You can do this in “Edit Query”>> Split Column >> by number of characters (10) .

     

    Then add two measures :

    min_timestamp_in_one_day = CALCULATE(MINX(Table1,Table1[starttime]),ALLEXCEPT(Table1,Table1[startdate]))

     

    max_timestamp_in_one_day = CALCULATE(MAXX(Table1,Table1[endtime]),ALLEXCEPT(Table1,Table1[enddate]))

     

    Noted you need to manually change the datatype format for all the relative columns and above two measures.

     

    Then you will get result like:

     

    >>> what is the minimum starting time for each process per day per region.

     

    So what result would you like to see if we are dealing with the table you post here?

     

    For example, I have a datasource like:

     

    If you want to calculate the earliest timestamp for a region,  you could use DAX like:

     

    Earliest_time_per_region = CALCULATE(MINX(Table1,Table1[starttime]),ALLEXCEPT(Table1,Table1[Region]))

     

    And you could add the column in the “ALLEXCEPT” function as you wish. For example, you could also use:

     

    Earliest_time_per_region_per_day = CALCULATE(MINX(Table1,Table1[starttime]),ALLEXCEPT(Table1,Table1[Region]),Table1[startdate])

     

    BR,

    Henry