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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
McGran
Frequent Visitor

Stock on Hand (Inventory) With Missing Dates for Multiple Sites

I have a stock file that uses [DATE FROM] and [DATE TO] rather than daily snapshots to track the stock position.  I want to report the daily stock position, filling missing dates with the last known position.

 

This code does exactly what I want in the column, but I'd like the row to also show the sum of stock across sites.

 

STOCK ON HAND =
CALCULATE (
    SUM ( 'ODS STOCK_LINECODE_DC'[AVAILABLE_STOCK] ),
    LASTNONBLANK (
        FILTER (
            ALLSELECTED ( 'ODS FINANCIAL_CALENDAR'[FINANCIAL_DATE] ),
            'ODS FINANCIAL_CALENDAR'[FINANCIAL_DATE]
                <= MAX ( 'ODS FINANCIAL_CALENDAR'[FINANCIAL_DATE] )
        ),
        CALCULATE ( SUM ( 'ODS STOCK_LINECODE_DC'[AVAILABLE_STOCK] ) )
    )
)

 

 

Without measure - Missing dates are returned as blanks and column totals sum stock

 

Loc1

Loc2

Total

June

636

4

640

2

321

0

321

3

 

1

1

4

315

2

317

5

 

1

1

 

With Current Measure - Missing dates are now correctly populated and column total shows closing stock position for the period.  However the row totals are not accounting for the newly populated data.

 

Loc1

Loc2

Total

June

315

1

1

2

321

0

321

3

321

1

1

4

315

2

317

5

315

1

1

 

Ideal Measure - Missing dates are still correctly populated and column total shows closing stock position for the period.  Row totals are account for the newly populated data.

 

Loc1

Loc2

Total

June

315

1

316

2

321

0

321

3

321

1

322

4

315

2

317

5

315

1

316

 

Is this possible?

 

1 ACCEPTED SOLUTION

Hello @McGran ,

Create a dim table as shown below:

Dim = VALUES('ODS STOCK_LINECODE_DC'[LOCATION_KEY])

Next, create a relationship as shown below:

Annotation 2020-08-06 151646.png

Finally, create a measure as follows:

Measure = SUMX(VALUES(Dim[LOCATION_KEY]),[STOCK ON HAND])

And you'll see:

1.PNG

For the related .pbix file, see pls see attachment.

Saludos
Kelly
Did I answer your question? Mark my position as a solution!

View solution in original post

11 REPLIES 11

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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