Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Filters Applied Through Multiples Tables

 

Contextualizing the dataset We had some users which made sales. Every user has an area where they are linked. It’s common the users don’t have sales every day. We are analyzing some specific users but not all from his area. 

 

There are a lot of users from a specific area, and we grouped their sales and called it a market. ( here, it’s common to have sales every day of the year).

 

The transactions of the user and the market transactions have a relationship with the Calendar Table, which I'm using to have a common axis between both tables, and also create other columns based on the date, like month year, year, quarter, day of the week, day of the month and etc... 

 

 

The sales_price  = sum of the Transactions value/sum of the Transactions sales

 

The objective’s to compare the User sales price by month against the Market sales price by month and by the User Area. 

 

And then I wrote the following measures: 

 

 

MarketTransactions[sales_price_by_area] = 
VAR area = Users[current_area]
VAR sales_price_calc = CALCULATE(
        DIVIDE(SUM(MarketTransactions[value]), SUM(MarketTransactions[sales]), 0),
        MarketTransactions,
        MarketTransactions[area] == area 
)
RETURN sales_price_calc

## --------------------------------------------

MarketTransactions[sales_price_by_engineering] = 
VAR sales_price_calc = CALCULATE(
        DIVIDE(SUM(MarketTransactions[value]), SUM(MarketTransactions[sales]), 0),
        FILTER(
            MarketTransactions,
            MarketTransactions[area] == "Engineering" 
        ), 
        USERELATIONSHIP('Calendar'[date], MarketTransactions[date])
)
RETURN sales_price_calc

## --------------------------------------------

Transactions[sales_price] = DIVIDE(SUM(MarketTransactions[value]),SUM(MarketTransactions[sales]), 0)

## --------------------------------------------

Users[current_area] = values(Users[area])

 

 

And Finally, I get the following Result: 

 

But the Market Sales Price it's wrong, the real value should be as the following image: 

 

 

 

There is an error occurring by the relation: Transaction Date to Calendar Date and from Calendar Date to Market Transaction Date.

I guess that what is occurring is: The users which don't have all the days of the transaction, will limit the dataset of the Market Transaction and this way will show the wrong values. 

Error example: 

 

 

But I didn’t find a way to show this value in a correct way keeping the relation to use the Calendar to filter the Date. 

 

If anyone could help me I would be very glad. 

Regards,

 

The files used in the example above: Files 

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Anonymous ,

    The value obtained from this graph is the value that has not been filtered by slicer

    The value you get from this graph is the result of selecting name = Emmanuel as the filter value in the user table, so the display will be different

     

    Best Regards,

    Liu Yang

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

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hii! Thanks for the quick response. 
      Well, it's not exactly this. When I plot Market Sales Price VS User Sales Price, I would compare The Users Sales price VS Entire Market Sales Price (as engineering for example), this is the right way: