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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

EARLIER function in Power BI

Hi all, I am new to this, I would like the 'Current Balance' by each line by date (from earliest to latest) and instead of aggregation by dates (items in red is not what I wanted - I need individual line balances).  I'm not sure which field should I use in my EARLIER function if not Invoice Date. I can't use Invoice No either since there will be same invoices but different amount. Line 1 calculation for 'Current Balance' is slightly different from the rest. Line 1 'Current Balance' should calculate Line 1 'Beginning Balance' - Line 1 'Amount', while the remaining lines 'Current Balance' calculation should be previous line 'Current balance' - current line 'Amount'.

 

Thanks and appreciate your help!

 

Current script:

Current Balance = -1 * SUMX(FILTER(Table1, Table1[Invoice Date ] <= (EARLIER(Table1[Invoice Date] )) ),Table1[ Amount]-Table1[Beginning Balance]) 

 

Current results:

Invoice NoInvoice DateAmountIndexBeginning BalanceCurrent Balance
23000000084/2/2019-235534.821-3269036.34-3033501.52
12000000194/6/2019251950.7620-3285452.28
12000000304/12/2019203745.1230-3489197.4
12000000514/20/201993364.9940-3582562.39
23000000404/24/2019-504408.760-2798926.49
23000000404/24/2019-279227.250-2798926.49
12000000764/26/201976893.4170-2875819.9
23000000874/30/2019-1018580-2848213.7
23000000884/30/2019-17421.290-2848213.7
12000000945/4/2019399520.88100-3247734.58
23000002025/24/201982225.93110-2910729.16
23000002025/24/2019-455695.88130-2910729.16
12000001535/24/201936464.53120-2910729.16
12000001755/31/201972929.06140-2983658.22
23000002686/6/2019-170258.4150-2813399.82
23000003406/26/2019-399520.88170-2405926.88
23000003406/26/2019-7952.06160-2405926.88
1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Anonymous 

You can use the INDEX column to get the running current balance 

Current Balance = 

SUMX(
    FILTER( Table7 , Table7[Index] <= EARLIER(Table7[Index] )),
    Table7[Amount] - Table7[Beginning Balance]
)

Fowmy_0-1601372247144.png

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
Fowmy
Super User
Super User

@Anonymous 

You can use the INDEX column to get the running current balance 

Current Balance = 

SUMX(
    FILTER( Table7 , Table7[Index] <= EARLIER(Table7[Index] )),
    Table7[Amount] - Table7[Beginning Balance]
)

Fowmy_0-1601372247144.png

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Thanks for the tip! Yes, this works according to what I need after I sort my Index column in ascending order.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.