Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Icon for Administrator rankAdministrator
2 years ago
Solved

Compare countries with 2 or 3 different targets

I have 1 table with the following columns: Countries, Sales, Products.
I need the user to be able to compare through graphs the sales of three countries of their choice. And that those graphics in turn can be filtered by product type.

In all 3 charts I want to use the same range for the Y-axis so that they are visually comparable. For them I need to calculate the maximum sales of the three countries chosen.

To do this, I have created 3 single-select segmentations on the same page so that 3 different countries (from the same table) can be selected. And an additional slicer to filter by product type:


And a measure that calculates the maximum sales of the products chosen for a single country:

I was advised to copy the Countries column into another table and create the following measure=

Medida =
CALCULATE(MAXX(
   ALLSELECTED('financials copy'[County_copy], SUM('financials'[Sales])),
   ALL('financials'[Country])
)

But this calculates the maximum of ALL countries, and the ones that are chosen have very few sales, the graph does not look good.

I have also tested the maximum sales for a single country depending on the products chosen:

Max_sales_by_Product =
MAXX(
   KEEPFILTERS(VALUES('financials'[Product])),
   CALCULATE(SUM('financials'[Sales]))
)​


But it does not allow you to filter by more than one country because if I activate the interactions for the three segmentations the result is:


Is it possible to do this type of filtering? How should I approach it?
  • Sadly it is not possible to apply two or more filters from different columns to the same column.

    This is due to the filters acting like an AND, no country can be Country = A AND Country = B.

    Or at least that is my understanding.


    The easiest way would be to have copies of the CountryName column in seperate tables.
    These are NOT joined to the main Country table.

    Put one in each of the 3 slicers.

    Create 3 measures that return the sales for the selected country:
    Country 1 =
    Calculate(
                  MaXx(Values(Table[Column]), [Your calculation])

                  ,MainCountryTable[Country] = SelectedValue(Country1[CountryName]))

     

    Place each of these in the Y-Axis of the 3 visuals allong with the MainCountryTable[Country] in the X axis.

    Then create your Y axis measure:

    Largest Y axis = 
    MAXX( {[Country 1],[Country 2],[Country 3]},[Value])

    I have put a sample file here: Swap Country.pbix

     

     

1 Reply

  • Sadly it is not possible to apply two or more filters from different columns to the same column.

    This is due to the filters acting like an AND, no country can be Country = A AND Country = B.

    Or at least that is my understanding.


    The easiest way would be to have copies of the CountryName column in seperate tables.
    These are NOT joined to the main Country table.

    Put one in each of the 3 slicers.

    Create 3 measures that return the sales for the selected country:
    Country 1 =
    Calculate(
                  MaXx(Values(Table[Column]), [Your calculation])

                  ,MainCountryTable[Country] = SelectedValue(Country1[CountryName]))

     

    Place each of these in the Y-Axis of the 3 visuals allong with the MainCountryTable[Country] in the X axis.

    Then create your Y axis measure:

    Largest Y axis = 
    MAXX( {[Country 1],[Country 2],[Country 3]},[Value])

    I have put a sample file here: Swap Country.pbix