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

Counting every time any product´s stock hits 0

Hi everyone!

I have a database of every movement of every product our company owns. This means that if I make a cumulative sum meassure, I get the stock at every point in time, of any article. What I want now is a meassure that calculates how many times a product hits 0 in any given period of time. I want, however, this meassure to be completely adaptable to any filter and context it is applied to. If I show it in a graph where I show the frequency of this event, but for a Brand with more than one product, I want it to show how many times each article hits 0. I also need this to work in a simple card, where if I select a time interval and a brand or group of products, it needs to tell me how, for every product and every date, how many times the stock was 0.

bacosta99_0-1677692940159.png

Here is my current progress, where I try to achieve this via a summarize table, but as you can see, it won´t do a cummulative sum and so I can´t proceed with the measure.

I don´t know if this is the way, but I will accept any solution to this problem.

Thanks!

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @bacosta99 ,

 

I think you can try EARLIER() function to calculate stock value.

Tabla =
SUMMARIZE (
    FILTER ( 'Movimientos de Stock', 'Movimientos de Stock'[CodArt] = 'ALCA04' ),
    'Unificador'[Codigo 1],
    'Calendar'[Date],
    "Stock",
        CALCULATE (
            SUM ( 'Movimientos de Stock'[Cantidad] ),
            FILTER (
                'Movimientos de Stock',
                'Movimientos de Stock'[CodArt] = EARLIER ( [CodArt] )
                    && 'Movimientos de Stock'[Date] <= EARLIER ( [Date] )
            )
        )
)

 

Best Regards,
Rico Zhou

 

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-rzhou-msft
Community Support
Community Support

Hi @bacosta99 ,

 

I think you can try EARLIER() function to calculate stock value.

Tabla =
SUMMARIZE (
    FILTER ( 'Movimientos de Stock', 'Movimientos de Stock'[CodArt] = 'ALCA04' ),
    'Unificador'[Codigo 1],
    'Calendar'[Date],
    "Stock",
        CALCULATE (
            SUM ( 'Movimientos de Stock'[Cantidad] ),
            FILTER (
                'Movimientos de Stock',
                'Movimientos de Stock'[CodArt] = EARLIER ( [CodArt] )
                    && 'Movimientos de Stock'[Date] <= EARLIER ( [Date] )
            )
        )
)

 

Best Regards,
Rico Zhou

 

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

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.