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
MichelleLash
New Member

Initial / close balance doesnt seem right

Hi community, 

im new to PBI, and been trying to create an Inital/Close balance, but havent been able so far, here is a little example PBIX 
the basic are: 

  • Inital Balance (the day the report is consulted will be Day 1) will be Inventory. Then from second day on, it will be Final Balance
  • Final Balance is Initial Balance - Sales of the day

This is the result I want 

MichelleLash_0-1709664890681.png

 But this is what i get

MichelleLash_1-1709664928120.png

My model 

MichelleLash_2-1709665039247.png

 

  • Dates (Date, Year, Month)

  • Table (Date, Item, Qty, Category)
    MichelleLash_4-1709665085813.png

     

  • Table 2 (Measures for Inventory, Sale, Inital Balance, Final Balance)

 

 

 

Inventory = CALCULATE( SUM('Table'[Qty]), 'Table'[Category] = "inv", ALLEXCEPT(Dates, Dates[Date] ))

Sale = CALCULATE( SUM('Table'[Qty] ), 'Table'[Category] ="sale")

Initial balance = 
var thisdate = MAX(Dates[Date] )
var vsales = 
CALCULATE(
    [Sale],
    REMOVEFILTERS(Dates ),
    'Table'[Date] < thisdate )
    RETURN  [Inventory] -vsales

Final balance = 
var thisdate = MAX(Dates[Date] )
var vsales = 
CALCULATE(
    [Sale],
    REMOVEFILTERS( Dates[Date] ),
    'Table'[Date] <= thisdate )
    RETURN [Inventory]- vsales

 

 

 

1 ACCEPTED SOLUTION
some_bih
Super User
Super User

Hi @MichelleLash if sale is outflow (it should be for balance logic) simply create new calculated column with if statement like on picture below and create simple measure  of SUM for that new column.

SUM of column should give you balance, so slice and filter as you wish.

 

some_bih_0-1709674434654.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






View solution in original post

2 REPLIES 2
some_bih
Super User
Super User

Hi @MichelleLash if sale is outflow (it should be for balance logic) simply create new calculated column with if statement like on picture below and create simple measure  of SUM for that new column.

SUM of column should give you balance, so slice and filter as you wish.

 

some_bih_0-1709674434654.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






gmsamborn
Super User
Super User

Hi @MichelleLash 

 

I made changes to [Initial Balance] and [_MyFinBal]  (my Final Balance).

 

 

Initial balance = 
VAR thisdate = MAX( 'Table'[Date] )
VAR vsales =
    CALCULATE(
        [Inventory] + [Arrive] - [Sale],
        REMOVEFILTERS( 'Table'[Date] ),
        'Table'[Date] < thisdate
    )
RETURN
    vsales



_MyFinBal = [Initial balance] + [Inventory] + [Arrive] - [Sale]

 

 

I didn't change any other measures.

 

Let me know if you have any questions.  I hope this helps.

 

MyFinBal.pbix

 

image.png

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! Prices go up Feb. 11th.

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.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.