Forum Discussion

rbpercussion's avatar
rbpercussion
Regular Visitor
3 years ago
Solved

Create a column with rows based on earliest value in another column

I have the below table and want to create a column that has the first value of weight (152.6) for every row.  I plan on using this to create another measure that shows % increase decrease over time

 

What is the easiest way to do this?

 

Thanks for your help

 

DateTimeWeight
1/29/202311:59:00 AM152.6
1/29/20236:44:00 PM153
1/30/20237:48:00 AM152.8
1/30/20238:45:00 PM151.4
1/31/20236:34:00 AM150.8
  • Hi,

    Write these calculated column formulas

    Date time = Data[Date]+Data[Time]
    First weight = LOOKUPVALUE(Data[Weight],Data[Date time],CALCULATE(MIN(Data[Date time]),ALL(Data)))

    Hope this helps.

10 Replies

  • Hi, 

     

    You could try something like this. Although I would suggest linking the "earliestWeight" to "Time" column, so you get the true first value, rather than just the minimum results from the "Weight" column.

     

     

    Average Weight = 
    VAR earliestWeight = CALCULATE (
        MIN ( 'Table'[Weight] ),
        FILTER ( 'Table', 'Table'[Date] = MIN ( 'Table'[Date] ) )
    ) 
    RETURN CALCULATE(AVERAGE( 'Table'[Weight]), ALLEXCEPT('Table','Table'[Date])) / earliestWeight

     

     


     

  • Hi,

    Write these calculated column formulas

    Date time = Data[Date]+Data[Time]
    First weight = LOOKUPVALUE(Data[Weight],Data[Date time],CALCULATE(MIN(Data[Date time]),ALL(Data)))

    Hope this helps.

    • rbpercussion's avatar
      rbpercussion
      Regular Visitor

      Hi Greg_Deckler ,

      That returns the minimum weight for the table.  What I am trying to return is the weight that corresponds to the earliest date

  • Hi,

    you can try 

    Measure = CALCULATE(sum('Table'[Weight]), INDEX(1,ORDERBY('Table'[Merged])))

     

    • rbpercussion's avatar
      rbpercussion
      Regular Visitor

      Column D is my desired output and how I would write it in excel:

       

       

  • This is my desired output in column D and how I would write it in excel: