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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
medkadri10
Regular Visitor

Opening and closing balance calculations

Hi Team,

 

i want to calculte the opeging & closing balance by DAX in Power BI,

 

I have created the closing balance of first Week 30: 

Cloasing Balance Week 30CALCULATE(SUM(DATA[Balance USD]), DATA[INCOME/EXPENSES  ]="Closing Balance")

 

Income_USD = CALCULATE(SUM(DATA[Balance USD]), DATA[INCOME/EXPENSES  ]="INCOME")
Expenses_USD = CALCULATE(SUM(DATA[Balance USD]), DATA[INCOME/EXPENSES  ]="EXPENSES")

 

So the closing Balance of week 30 is the opening balance of Week 31

the closing Balance of week 31 is the opening balance of Week 32
like the table excel :

Row LabelsClosing BalanceINCOMEEXPENSESClosing Balance
WEEK 30  423 232  423 232
WEEK 31   423 232   219 646-    465 967 176 912
WEEK 32  176 912               34-      49 744 127 202
WEEK 33  127 202   509 788-    535 240 101 750
Spoiler
 


Thanks

 

file 

1 ACCEPTED SOLUTION
mickey64
Super User
Super User

Step 0: I use these data.

mickey64_0-1726146635597.png

 

Step 1: I make some measures below.

M_WeekNo = WEEKNUM(MAX('Table'[Row Labels]))

 

M_Opening = SUMX(FILTER('Table','Table'[INCOME/EXPENSES]="Opening"),'Table'[Balance])

M_Income = SUMX(FILTER('Table','Table'[INCOME/EXPENSES]="INCOME"),'Table'[Balance])

M_Expenses = SUMX(FILTER('Table','Table'[INCOME/EXPENSES]="EXPENSES"),'Table'[Balance])

 

M_Opening RT = CALCULATE([M_Opening],FILTER(ALL('Table'),'Table'[Row Labels]<=MAX('Table'[Row Labels])))

M_Income RT = CALCULATE([M_Income],FILTER(ALL('Table'),'Table'[Row Labels]<=MAX('Table'[Row Labels])))

M_Expenses RT = CALCULATE([M_Expenses],FILTER(ALL('Table'),'Table'[Row Labels]<=MAX('Table'[Row Labels])))

 

M_Closing Balance = [M_Opening RT]+[M_Income RT]+[M_Expenses RT]

M_Opening Balance = CALCULATE([M_Closing Balance],ALL('Table'),DATEADD('Table'[Row Labels],-7,DAY))

 

Step 2: I make a matrix.

mickey64_1-1726146950617.png

 

 

View solution in original post

3 REPLIES 3
medkadri10
Regular Visitor

Thank you 

mickey64
Super User
Super User

Step 0: I use these data.

mickey64_0-1726146635597.png

 

Step 1: I make some measures below.

M_WeekNo = WEEKNUM(MAX('Table'[Row Labels]))

 

M_Opening = SUMX(FILTER('Table','Table'[INCOME/EXPENSES]="Opening"),'Table'[Balance])

M_Income = SUMX(FILTER('Table','Table'[INCOME/EXPENSES]="INCOME"),'Table'[Balance])

M_Expenses = SUMX(FILTER('Table','Table'[INCOME/EXPENSES]="EXPENSES"),'Table'[Balance])

 

M_Opening RT = CALCULATE([M_Opening],FILTER(ALL('Table'),'Table'[Row Labels]<=MAX('Table'[Row Labels])))

M_Income RT = CALCULATE([M_Income],FILTER(ALL('Table'),'Table'[Row Labels]<=MAX('Table'[Row Labels])))

M_Expenses RT = CALCULATE([M_Expenses],FILTER(ALL('Table'),'Table'[Row Labels]<=MAX('Table'[Row Labels])))

 

M_Closing Balance = [M_Opening RT]+[M_Income RT]+[M_Expenses RT]

M_Opening Balance = CALCULATE([M_Closing Balance],ALL('Table'),DATEADD('Table'[Row Labels],-7,DAY))

 

Step 2: I make a matrix.

mickey64_1-1726146950617.png

 

 

medkadri10
Regular Visitor

Need Help

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.