Forum Discussion

patoku0207's avatar
patoku0207
Frequent Visitor
4 years ago
Solved

Max for date and time 2 columns

Hello, 

First,sorry for my english, I'm french.

This forum is incredible and very helpful.

I'm new and I need help for a calculated column.

I'm trying to find the value for a max date and time with filters.

 

Suffix time is a incremented number when date and time are similars.

So the very last date and time is date, max time , max suffix.

 

Itemnumberdatetimesuffix timebalance
11234520220131295311100
11234620220131357811100
19999999992022020115385411500
11234720220131295311127
21234720220131475213544
2999999999202201314562413748
245787202201314562423750
2999999999202202017588625000

 

Resultat : 

Itemnumberdatetimesuffix timebalance
1123452022013129531 
1123462022013135781 
1999999999202202011538541 
11234720220131295311127
2123472022013147521 
299999999920220131456241 
245787202201314562423750
299999999920220201758862 

 

Im trying to find the balance for each item, each date, max time and max suffix time, excluding number = 99999999.

 

Thanks for your help

Pat

 

  • Hi patoku0207 ,

     

    Just so I understand correctly, you would like to return the balance per item and number which has the highest date. If two dates are equal, then we shall take the higher time. If even these two times are equal, we shall take the higher time suffix. For the calculation we must not consider the rows with number = 999999999.

     

    This is my result:

     

    This is the measure I used:

    TomsBalanceMeasure = 
    VAR _maxValue = 
    CALCULATE (
        MAXX ( Table, Value( Table[date] & Table[time] & Table[suffix time] ) ),
        ALLEXCEPT ( Table, Table[Item] ),
        Table22[number] <> 999999999
    )
    RETURN
    CALCULATE ( 
      MAX ( Table[balance] ), 
        VALUE ( Table[date] & Table[time] & Table[suffix time] ) == _maxValue  
    )

     

    Does this solve your issue? 🙂

     

    /Tom

    https://www.tackytech.blog/

    https://www.instagram.com/tackytechtom/

4 Replies

  • tackytechtom's avatar
    tackytechtom
    Icon for Most Valuable Professional rankMost Valuable Professional

    Hi patoku0207 ,

     

    Just so I understand correctly, you would like to return the balance per item and number which has the highest date. If two dates are equal, then we shall take the higher time. If even these two times are equal, we shall take the higher time suffix. For the calculation we must not consider the rows with number = 999999999.

     

    This is my result:

     

    This is the measure I used:

    TomsBalanceMeasure = 
    VAR _maxValue = 
    CALCULATE (
        MAXX ( Table, Value( Table[date] & Table[time] & Table[suffix time] ) ),
        ALLEXCEPT ( Table, Table[Item] ),
        Table22[number] <> 999999999
    )
    RETURN
    CALCULATE ( 
      MAX ( Table[balance] ), 
        VALUE ( Table[date] & Table[time] & Table[suffix time] ) == _maxValue  
    )

     

    Does this solve your issue? 🙂

     

    /Tom

    https://www.tackytech.blog/

    https://www.instagram.com/tackytechtom/

  • patoku0207's avatar
    patoku0207
    Frequent Visitor

    Hello,

     

    If its too hard, I just want to find the latest date for each date for each item.( ignore the number filter).

    The latest date is a combinaison of date, max time, max suffix

     

    Ex :

    Item 1 : 20220131   3578 is the max time   1 is the max suffix

    Item 2 : 20220131   45624 is the max time   2 is the max suffix

     

    Thanks in advance for your help.

    Pat

  • patoku0207's avatar
    patoku0207
    Frequent Visitor

    Hello tomfox,

     

    Thanks for your help, this solved my issue 

     

    Congrats

    Pat

     

     

  • patoku0207's avatar
    patoku0207
    Frequent Visitor

    Hello,

     

    It wont let me validate the measure

     

     

    Thanks for help.

    Pat