Forum Discussion

ChristophEmrich's avatar
ChristophEmrich
Frequent Visitor
7 years ago
Solved

Divide values from different tables

Hi all,   I am trying to calculate the market share of certain products in a specfic country, in a specific year based on filtered values. For that I have two tables: Table_Sales and Table_Market a...
  • Anonymous's avatar
    Anonymous
    7 years ago

    Hi,

    I think you need two calculated tables and three measures.

     

    Table 1: Calendar

     

    Calendar =
    DISTINCT ( UNION ( ALL ( Table_Market[Year] ), ALL ( Table_Sales[Year] ) ) )

    Table 2: Countries

    Countries =
    DISTINCT (
        UNION ( ALL ( Table_Market[Country] ), ALL ( Table_Sales[Country] ) )
    )

    Relationships:

    Countries[Country] -> Table_Market[Country]
    
    Countries[Country] -> Table_Sales[Country]
    
    Calendar[Year] -> Table_Market[Year]
    
    Calendar[Year] -> Table_Sales[Year]

    All relationships are one to many with cross-filtering as single.

     

    Measure 1: MarketSize

    MarketSize = SUMX(Table_Market,Table_Market[Market Volume])

    Measure 2: SalesVolume

    SalesVolume = SUMX(Table_Sales,Table_Sales[Sales])

    Measure 3: MarketShare %

    Market Share = DIVIDE(Table_Sales[SalesVolume],Table_Market[MarketSize],0)

    For the slicers, use the Calendar[Year] and Countries[Country] fields.

     

    MarketSize, SalesVolume, and MarketShare% will be correctly displayed.