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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
smko
Helper I
Helper I

Dynamic Stock balance according to PIC as at selected period

Greetings BI community, I came across an interesting business requirement where the report has to show the stock balance of Person In Charge (PIC) as at selected period. Each PIC will have a table report (hard code to specific PIC at visual filter) showing only stock balance of his brand.

 

InventoryMovement

DateBrandPICValue
2023-01-01XA1000
2023-02-01XA-100
2023-03-01XB500
2023-06-30XB-800
2023-01-01YA5000

 

Changelog of PIC and brand

BrandPICStartDateEndDate
XA2023-01-012023-02-28
XB2023-03-012023-12-31
YA2023-02-012023-06-30

 

For example:
- Selected date filter is Q1, report of PIC A should only show stock balance for Brand X as at 2023-02-28 and Brand Y as at 2023-03-31, report of PIC B show stock balance for Brand X as at 2023-03-31

- Selected date filter is Q2, report of PIC A should only show stock balance for Brand Y as at 2023-06-30, report of PIC B show stock balance for Brand X as at 2023-06-30

 

Desired result:

smko_0-1698222795325.png


With the below code Im unable to achieve the desired result as it only calculate the value between each PIC StartDate and EndDate. The current PIC value in InventoryMovement table is following the StartDate EndDate, maybe there is a better model for this?

 

Stock Balance = 
VAR _MaxDate = MAX('Calendar'[Date])
RETURN
CALCULATE(
    SUM(InventoryMovement[Value]),
    ALLSELECTED(PIC),
    'Calendar'[Date] <= _MaxDate
)

 


This link contains the pbix file: test.pbix

2 REPLIES 2
Anonymous
Not applicable

Hi @smko ,

I have some doubt.

Why is the X in PIC Part A of 2023 Q1 900, but the X in PIC Part B of 2023 Q1 is 1400? Why doesn't PIC B ignore the PIC distinction? I may have missed some details, please help.

 

 

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.

 

 

 

 

Hi @Anonymous , the idea is to get stock balance up to the EndDate of the PIC. For Brand X in Q1, since EndDate of PIC A is 2023-02-28, the stock balance as at that date is only 900; while PIC B took over from 2023-03-01 onwards, at the end of Q1 the stock balance should have 1400.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

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