cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
TomTank1504 Frequent Visitor
Frequent Visitor

Stock usage over time

Hi everyone,

I am trying to calculate stock usage per day to make ordering easier.

I have several tables:

1. Ingredients

2. Menu Items

3. Date Table

4. Recipes Table

 

Recipes.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

5. Menu Item Sales Table

 

ItemSales.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

My goal is this manual Excel example below:

 

 08 08 201909 08 201910 08 201911 08 201912 08 201913 08 201914 08 201915 08 201916 08 201917 08 201918 08 2019
Soup Roasted Pumpkin           
Soup Roasted Tomato           
Ciabatta Rolls W80           
ZOOP Brown Large Bag S0.20           
ZOOP Brown Roll Bag S0.02           
Serviette 2 Ply           

 

Relationships are:

 

Ingredients (1-Many) Recipes

Menu Items (1-Many) Recipes

Menu Items (1-Many) Menu Items Sales

Date (1-Many) Menu Items Sales

 

Any advice?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Icey Senior Member
Senior Member

Re: Stock usage over time

Hi @TomTank1504 ,

 

Maybe you can try this:

1. Do not create relationships using 'Menu Table', and create 'Many-to-Many' relationship between 'Recipes Table' and 'Menu Item Sales Table' instead.

mm.PNG

2. Create a measure.

Ingredient Sales =
SUMX (
    ItemSales,
    CALCULATE (
        MAX ( ItemSales[Qty Sold] ),
        ALLEXCEPT (
            'Granular Recipes',
            'Granular Recipes'[Item Name],
            'Granular Recipes'[Ingredient]
        )
    )
        * CALCULATE (
            MAX ( 'Granular Recipes'[Quantity] ),
            ALLEXCEPT ( ItemSales, ItemSales[Date], ItemSales[Item Name] )
        )
)

mm2.PNG

Best Regards,

Icey

 

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

3 REPLIES 3
Icey Senior Member
Senior Member

Re: Stock usage over time

Hi @TomTank1504 ,

 

Can you give me some samples of each tables? So that I can create a complete data model.

 

Best Regards,

Icey

Icey Senior Member
Senior Member

Re: Stock usage over time

Hi @TomTank1504 ,

 

Maybe you can try this:

1. Do not create relationships using 'Menu Table', and create 'Many-to-Many' relationship between 'Recipes Table' and 'Menu Item Sales Table' instead.

mm.PNG

2. Create a measure.

Ingredient Sales =
SUMX (
    ItemSales,
    CALCULATE (
        MAX ( ItemSales[Qty Sold] ),
        ALLEXCEPT (
            'Granular Recipes',
            'Granular Recipes'[Item Name],
            'Granular Recipes'[Ingredient]
        )
    )
        * CALCULATE (
            MAX ( 'Granular Recipes'[Quantity] ),
            ALLEXCEPT ( ItemSales, ItemSales[Date], ItemSales[Item Name] )
        )
)

mm2.PNG

Best Regards,

Icey

 

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

TomTank1504 Frequent Visitor
Frequent Visitor

Re: Stock usage over time

@Icey ,

 

Thank you SO much - that worked perfectly.

 

If I should post this as a new query, let me know, but I'm trying to work out the average usage of specific ingredients (broken down using a slicer) per weekday. When I try an AVERAGEX function it returns the average for the sum of all the Sundays, for example, meaning it shows the usage for the Sundays for the whole month instead of an average Sunday.

 

Any clues?

 

Regards,

 

Tom 

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 124 members 1,503 guests
Please welcome our newest community members: