cancel
Showing results for
Did you mean:
Frequent Visitor

## Stock and sales join

Hi,

I'm doing Restaurant stock control model and got this problem.

there are 3 tables

1. Sales
2. Stock
3. Recipes

In sales there are cocktails which contain different ingredients (taken from Recipes table).

I'd like to create model, where after selling cocktail, it will take values from Recipes and distract from Stock Table.

see attached file. thanks in advance

https://1drv.ms/u/s!Aucu3BmZNQw-p5dwUIwMFklif5zJDQ?e=rMpNaa

1 ACCEPTED SOLUTION
Community Support

At first, rename “Quantity” column to “Quantity2” in the “Sales” table and crossjoin these two tables.

```temp =
CROSSJOIN ( Recipes, Sales )
```

Create a new calculated column to count total amount.

```total amount =
IF ( temp[Name] = temp[Item], temp[Quantity] * temp[Quantity2], 0 )
```

Then create a new table to retain fields necessary.

```Final table =
SELECTCOLUMNS (
'temp',
"Ingredient", 'temp'[Ingredient],
"Date", 'temp'[Date],
"Column", 'temp'[total amount]
)
```

Now, you can use matrix visual to display it.

Best Regards,

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

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
2 REPLIES 2
Community Support

At first, rename “Quantity” column to “Quantity2” in the “Sales” table and crossjoin these two tables.

```temp =
CROSSJOIN ( Recipes, Sales )
```

Create a new calculated column to count total amount.

```total amount =
IF ( temp[Name] = temp[Item], temp[Quantity] * temp[Quantity2], 0 )
```

Then create a new table to retain fields necessary.

```Final table =
SELECTCOLUMNS (
'temp',
"Ingredient", 'temp'[Ingredient],
"Date", 'temp'[Date],
"Column", 'temp'[total amount]
)
```

Now, you can use matrix visual to display it.

Best Regards,

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

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
Frequent Visitor

Thanks Mate. It works

Announcements

#### Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

#### Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

#### Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

#### Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors