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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
olegkazanskyi
Helper II
Helper II

Getting Item Components Amount Based on Sales

 

I have a simple data model of pizza sales with three tables:

1. Fact_Sales

2. DIM_Product

3. DIM_Ingridients

olegkazanskyi_2-1689629366214.png

 

Every Pizza has a specific amount of ingredients.

I would like to know how many ingredients I use per month based on sales of pizzas.

Sorry, I can't get how to build this calculation.

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Try

Ingredient Usage =
SUMX (
    'DIM_Ingredients',
    VAR Sales =
        SUMX ( RELATEDTABLE ( 'FACT_Sales' ), 'FACT_Sales'[quantity] )
    VAR Result = Sales * 'DIM_Ingredients'[Usage, KG]
    RETURN
        Result
)

View solution in original post

4 REPLIES 4
johnt75
Super User
Super User

Try

Ingredient Usage =
SUMX (
    'DIM_Ingredients',
    VAR Sales =
        SUMX ( RELATEDTABLE ( 'FACT_Sales' ), 'FACT_Sales'[quantity] )
    VAR Result = Sales * 'DIM_Ingredients'[Usage, KG]
    RETURN
        Result
)

Unfortunately, I got blank values as a result.
I'm sharing a dataset just for any case.
Link

The relationship between sales and product is invalid - the keys in the product table include the size whereas the sales table doesn't.

Thank you! You're a life saviour.
A silly mistake

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors