Forum Discussion

alsm's avatar
alsm
Icon for Helper III rankHelper III
3 years ago
Solved

Creating a slicer with others category

Hello,

I wish to create a slicer for currencies in my data. I wish some of the currencies to be listed explicitly e.g. (USD, GPB, CAD, CHF,...) and other currencies (e.g. MXN, RUB, CNY...) to be in 'Other' category and all the calculations are performed accordingly i.e. Sales with USD selected has total sales volume with ccy = USD where as when user selects 'Other' it is total sales of all the currencies in Other category. 

 

Which would be the most ideal way to go about it?

  • ok, figured it out ... 

    steps involved

    1. Create a table with distinct currencys in the table
    2. Then add a new column with a switch statement where one adds 'Others'
    3. Create a relationship with the original table for the filter to work

    DAX code

    Ccy List =
    ADDCOLUMNS (
        DISTINCT ( DataTable[Positions.Currency] ),
        "Currency Group",
            SWITCH (
                TRUE (),
                [Positions.Currency] = "CHF", "CHF",
                [Positions.Currency] = "USD", "USD",
                [Positions.Currency] = "EUR", "EUR",
                "Others"
            )
    )

1 Reply

  • alsm's avatar
    alsm
    Icon for Helper III rankHelper III

    ok, figured it out ... 

    steps involved

    1. Create a table with distinct currencys in the table
    2. Then add a new column with a switch statement where one adds 'Others'
    3. Create a relationship with the original table for the filter to work

    DAX code

    Ccy List =
    ADDCOLUMNS (
        DISTINCT ( DataTable[Positions.Currency] ),
        "Currency Group",
            SWITCH (
                TRUE (),
                [Positions.Currency] = "CHF", "CHF",
                [Positions.Currency] = "USD", "USD",
                [Positions.Currency] = "EUR", "EUR",
                "Others"
            )
    )