Search code examples
powerbipowerbi-desktoppowerbi-datasourcepower-bi-report-serverpowerbi-custom-visuals

How to create slicer from column name


I have a sample table as shown below:

Table

Quarter Month   Status  Debit   Digital Internal    IVT Risk
Q1  Jan'22  Plan    57  92  33  9   60
        Actuals 46  92  33  9   60
    Feb'22  Plan    58  72  36  8   65
        Actuals 50  72  37  8   65
    Mar'22  Plan    71  28  30  22  2
        Actuals 44  28  29  22  2

Here is the report:

enter image description here

I am creating a hierarchical bar chart out of it

I have to make a slicer/dropdown filter based on some column name as shown below:

Columns

How to create slicer without affecting hierarchical bar chart.

I have created a measure like:

Parameter = {
    ("Digital", NAMEOF('Power BI Fact Table'[Digital]), 0),
    ("Debit", NAMEOF('Power BI Fact Table'[Debit]), 1),
    ("Internal", NAMEOF('Power BI Fact Table'[Internal]), 2),
    ("IVT", NAMEOF('Power BI Fact Table'[IVT]), 3),
    ("Risk", NAMEOF('Power BI Fact Table'[Risk]), 4)
}

But it is not changing bar chart after selection.


Solution

  • The problem here is the half-baked data model and especially a pivot table will bring you nowhere in Power BI. So the work starts in Power Query, where you have to unpivot your Attribute columns Debit, Digital, Internal, IVT and Risk to get a stacked table like shown below

    Table.UnpivotOtherColumns(#"Changed Type", {"Quarter", "Month", "Status"}, "Attribute", "Value")
    

    enter image description here

    From here everything becomes plain vanilla and you can simply pull in the new Attribute column and use it as a slicer:

    enter image description here