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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Cost per product and country - how can I create that table?

SarahSarah_0-1671445150526.png

I want to create a table like the image above. The costs per country and product are the sum of 3 different cost centers, which are stored individually in Power Bi. For example, the cost of Country A and Product A listed here is $10. However, this €10 consists of three costs €3 + €3 + €4. The goal is to be able to filter the data by year, period (i.e. quarter 1, 2, 3, 4) and also cost section 1-3. I need filters that filter all the data on the page by country, quarter, and cost section, and filters within the visual so that the visual only sees the cost per product of this one country A and product A. My question would now be how to create this. Could someone help me?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

I will create a sample to show you more details and give you some advice.

Firstly, your table should look like as below.

RicoZhou_0-1671520922335.png

Then create dim tables like DimYear/DimPeriod/Dim Cost Section... and so on. Data model should look like as below.

RicoZhou_1-1671521000774.png

For reference:

Understand star schema and the importance for Power BI

Measure:

Measure = 
VAR _SUM_CountryAndProduct =
    CALCULATE ( SUM ( 'Table'[Sales] ) )
VAR _Count =
    CALCULATE (
        COUNT ( DimProduct[Product] ),
        FILTER ( 'Table', _SUM_CountryAndProduct <> BLANK () )
    )
VAR _Weight_avg_per_country =
    DIVIDE ( _SUM_CountryAndProduct, _Count )
RETURN
    IF (
        HASONEVALUE ( DimProduct[Product] ),
        IF (
            _SUM_CountryAndProduct = BLANK (),
            "Not available",
            _SUM_CountryAndProduct
        ),
        _Weight_avg_per_country
    )

Result is as below.

RicoZhou_2-1671521039892.png

 

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
Anonymous
Not applicable

Hi @Anonymous ,

 

I will create a sample to show you more details and give you some advice.

Firstly, your table should look like as below.

RicoZhou_0-1671520922335.png

Then create dim tables like DimYear/DimPeriod/Dim Cost Section... and so on. Data model should look like as below.

RicoZhou_1-1671521000774.png

For reference:

Understand star schema and the importance for Power BI

Measure:

Measure = 
VAR _SUM_CountryAndProduct =
    CALCULATE ( SUM ( 'Table'[Sales] ) )
VAR _Count =
    CALCULATE (
        COUNT ( DimProduct[Product] ),
        FILTER ( 'Table', _SUM_CountryAndProduct <> BLANK () )
    )
VAR _Weight_avg_per_country =
    DIVIDE ( _SUM_CountryAndProduct, _Count )
RETURN
    IF (
        HASONEVALUE ( DimProduct[Product] ),
        IF (
            _SUM_CountryAndProduct = BLANK (),
            "Not available",
            _SUM_CountryAndProduct
        ),
        _Weight_avg_per_country
    )

Result is as below.

RicoZhou_2-1671521039892.png

 

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.