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
gkalandadze
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
v-eachen-msft
Community Support
Community Support

Hi @gkalandadze ,

 

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.4-1.PNG

 

Best Regards,

Eads

 

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.

View solution in original post

2 REPLIES 2
v-eachen-msft
Community Support
Community Support

Hi @gkalandadze ,

 

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.4-1.PNG

 

Best Regards,

Eads

 

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.

Thanks Mate. It works

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.