Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

How to get previous record in Power Bi

I have a table like below which shows the Invoice amount at various dates. The invoice amount would remain the same between two dates. For ex, amount is 600 on 5-1-2021 and would remain the same till 5-8-2021, at which point it changes to 500. If I want to view the invoice amount for any intermediate date (say 5-13-2021, amount = 500) how do I go about doing this in Power BI. Thanks.

 

DateInvoice NumberAmount
5-1-20211234600
5-8-20211234500
5-15-20211234400
5-22-20211234300
5-29-20211234200
6-5-20211234100
  • Anonymous , Try a measure like

     

    Measure =
    VAR __sel = maxx(allselected('Date'), 'Date'[Date])
    VAR __id = MAX ('Table'[Invoice Number] )
    VAR __date = CALCULATE ( MAXX(filter('Table', [Date] <__sel),'Table'[Date] ), ALLSELECTED ('Table' ), 'Table'[Invoice Number] = __id )
    CALCULATE ( max ('Table'[CHANNEL] ), VALUES ('Table'[Invoice Number] ),'Table'[Invoice Number] = __id,'Table'[Date] = __date )

     

5 Replies

  • Anonymous , Try a measure like

     

    Measure =
    VAR __sel = maxx(allselected('Date'), 'Date'[Date])
    VAR __id = MAX ('Table'[Invoice Number] )
    VAR __date = CALCULATE ( MAXX(filter('Table', [Date] <__sel),'Table'[Date] ), ALLSELECTED ('Table' ), 'Table'[Invoice Number] = __id )
    CALCULATE ( max ('Table'[CHANNEL] ), VALUES ('Table'[Invoice Number] ),'Table'[Invoice Number] = __id,'Table'[Date] = __date )

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      amitchandak 

      Thanks for your reply. Could you please explain what this [CHANNEL] means.

       

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    The measure works fine for a single and multiple invoice. But how should we arrive at total amount for a set of selected invoices or all invoices put together. Thanks.

     

    RatpayInvoiceDate
    60012345/1/2021
    50012345/8/2021
    40012345/15/2021
    30012345/22/2021
    20012345/29/2021
    10012346/5/2021
    35056785/3/2021
    25056785/10/2021
    15056785/17/2021
    5056785/24/2021
    • Anonymous's avatar
      Anonymous
      Not applicable

       

      BI visual for your reference