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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
FilipFireFlyBI
Resolver I
Resolver I

From inventory position to inventory range with correct totals

Hi all,

 

I have a table with inventory positions per week, and sometimes a week is missing.

I want a matrix table in Power BI with the inventory positions per day, where also the total inventory position per day is correct.
I created a small example dataset with just two articles, and created this measure using LASTNONBLANK.

The totals are sometimes incorrect (red) and correct (green) summed.

Can you help so that also the totals in the red area is correctly summed?

link to dataset:  https://www.dropbox.com/s/vie3yol8kduq6y3/From%20inventory%20position%20to%20inventory%20range%20wit...

 

 

FilipFireFlyBI_0-1679988703985.png

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @FilipFireFlyBI 

 

You can try the following methods.

Measure = 
VAR _a =
    ADDCOLUMNS ( DISTINCT ( ALL ( 'fact Stock positions'[Article code] ) ),
        "Date", CALCULATE ( MAX ( 'fact Stock positions'[Date] ),
                 FILTER ( ALL ( 'fact Stock positions' ),
                    [Article code] = EARLIER ( 'fact Stock positions'[Article code] )
                        && [Date] <= MAX ( 'dim Date'[Date] ) ) ) )
VAR _b =
    SUMX ( _a,
        CALCULATE ( SUM ( 'fact Stock positions'[Quantity in pcs] ),
            FILTER ( ALL ( 'fact Stock positions' ),
                [Article code] = EARLIER ( 'fact Stock positions'[Article code] )
                    && [Date] = EARLIER ( [Date] ) ) ) )
RETURN
    IF ( ISINSCOPE ( 'fact Stock positions'[Article code] ),
        [Stock position to range measure],
        _b
    )

vzhangti_0-1680157969443.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

 

View solution in original post

1 REPLY 1
v-zhangti
Community Support
Community Support

Hi, @FilipFireFlyBI 

 

You can try the following methods.

Measure = 
VAR _a =
    ADDCOLUMNS ( DISTINCT ( ALL ( 'fact Stock positions'[Article code] ) ),
        "Date", CALCULATE ( MAX ( 'fact Stock positions'[Date] ),
                 FILTER ( ALL ( 'fact Stock positions' ),
                    [Article code] = EARLIER ( 'fact Stock positions'[Article code] )
                        && [Date] <= MAX ( 'dim Date'[Date] ) ) ) )
VAR _b =
    SUMX ( _a,
        CALCULATE ( SUM ( 'fact Stock positions'[Quantity in pcs] ),
            FILTER ( ALL ( 'fact Stock positions' ),
                [Article code] = EARLIER ( 'fact Stock positions'[Article code] )
                    && [Date] = EARLIER ( [Date] ) ) ) )
RETURN
    IF ( ISINSCOPE ( 'fact Stock positions'[Article code] ),
        [Stock position to range measure],
        _b
    )

vzhangti_0-1680157969443.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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