Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Need help on table or formula

Hello,

 

I'm having issue regarding formula, I'm new to this languange and currently studying it.

here's what I got stucked.

 

So I have this Table

Item#Time StampHourQuantity
A1:43:01 PM131
B1:48:01 PM131
C1:47:01 PM131
A2:39:03 PM141
B2:43:12 PM141
C3:59:13 PM151
C4:03:53 PM161
C4:12:29 PM161
C4:12:29 PM161

 

But I need to summarize the report by hourly to show on the graph.

The challenging part for me is I need to rank by hour the item # thats the earliest (or lowest timestamp), and sum the total results under all hours. If it doesnt make sense. basically these is what im looking for.

 

Rank lowest time stamp - shows the item# with the lowest time stamp for that hour.

 

HourRank Lowest Time StampResults
13A3
14A2
15C1
16C3

 

 

  • Anonymous  Please try this as a "New Table"

     

    Test11Out = 
    VAR _Time = ADDCOLUMNS(SUMMARIZE(Test11,Test11[Hour],"MinTime",MIN(Test11[Time Stamp])),"Item",LOOKUPVALUE(Test11[Item#],Test11[Hour],[Hour],Test11[Time Stamp],[MinTime]))
    VAR _Totals = SUMMARIZE(Test11,Test11[Hour],"Results",SUM(Test11[Quantity]))
    RETURN NATURALINNERJOIN(_Time,_Totals)

     

    Added the time as well, just for reference. 

2 Replies

  • jthomson's avatar
    jthomson
    Solution Sage

    Maybe look to add an index/ranking column within each hour in your dataset and use the lowest value of said index as a filter? Ranking within a group's a fairly common problem so you should be able to search and find something that works within your setup?

  • PattemManohar's avatar
    PattemManohar
    Community Champion

    Anonymous  Please try this as a "New Table"

     

    Test11Out = 
    VAR _Time = ADDCOLUMNS(SUMMARIZE(Test11,Test11[Hour],"MinTime",MIN(Test11[Time Stamp])),"Item",LOOKUPVALUE(Test11[Item#],Test11[Hour],[Hour],Test11[Time Stamp],[MinTime]))
    VAR _Totals = SUMMARIZE(Test11,Test11[Hour],"Results",SUM(Test11[Quantity]))
    RETURN NATURALINNERJOIN(_Time,_Totals)

     

    Added the time as well, just for reference.