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
guruvammal
Frequent Visitor

Inventory Ledger

Hi team I need help

guruvammal_0-1708949302521.png

In qlik can calculate closing qty but not able to calculate in power bi 

Qilk Expression

Closing Qty = Rangesum(above(total Sum ({<Trans_Date={"<=$(=MAX(Stock_Date))"}>} IF(PLUSORMINUS='p', QTY, -QTY)),0, RowNo()))

guruvammal_1-1708949716290.png

Power BI Measure

CLosing = CALCULATE(CALCULATE(SUM(STOCKVALUE[Qty]),FILTER(STOCKVALUE,STOCKVALUE[PLUSORMINUS]= "P")) ,WINDOW(0,ABS,0,REL, ALL(STOCKVALUE[ITEMID], STOCKVALUE[DOCDATE]), ORDERBY([Date]))) - CALCULATE(SUM(STOCKVALUE[Qty]), WINDOW(0,ABS,0,REL, ALL(STOCKVALUE[ITEMID], STOCKVALUE[DOCDATE]), ORDERBY([Date])), FILTER(STOCKVALUE,STOCKVALUE[PLUSORMINUS]= "M"))

this measure not calculate correct closing qty

3 REPLIES 3
Anonymous
Not applicable

Hi @guruvammal , 

Create a Calculated Column for Adjusted Quantity: 

Adjusted Qty = IF(STOCKVALUE[PLUSORMINUS] = "P", STOCKVALUE[Qty], 0-STOCKVALUE[Qty])

 Create a measure:

Closing Qty = 
CALCULATE(
    SUM(STOCKVALUE[Adjusted Qty]),
    FILTER(
        ALL(STOCKVALUE),
        STOCKVALUE[DOCDATE] <= MAX(STOCKVALUE[DOCDATE])
    )
)

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

@Anonymous 

guruvammal_1-1709011197892.png

Is not give the correct closing qty 

Excepted closing qty /Output

guruvammal_2-1709011296660.png

 

Anonymous
Not applicable

Hi @guruvammal ,

Is it a total value error? If so, please create another measure.

 

result =
var _b = SUMMARIZE(STOCKVALUE,STOCKVALUE[DATE],"aaa",STOCKVALUE[Closing Qty])
return
IF(HASONEVALUE(STOCKVALUE[date]),[Closing Qty],SUMX(_b,[aaa]))

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

 

If the whole formula is not correct, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.