Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

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
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@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 )

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

5 REPLIES 5
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
Not applicable

MicrosoftTeams-image (6).png

 

BI visual for your reference

Anonymous
Not applicable

Thanks @amitchandak , it works peacefully.

amitchandak
Super User
Super User

@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 )

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak 

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

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.