Kavita Rupani
Kavita Rupani

Reputation: 31

Apply Top 10 filter according to selected value of Field Parameter-Power BI

I have a Bar Chart Visual and for its X axis values(Area, Population, Birth Rate, etc) I've created a field parameter. So the visual displays population by country name or Area by country name depending on the value selected by user. But I want to add 2 buttons namely All Countries and Top 10 countries and if the user clicks on top 10 countries and selects value as Birth Rate from field parameter, then the visual should display top 10 countries according to birth rate. The required Dashboard design

I've created the entire dashboard, but I am not able to apply topN filter. Other than the default columns in field parameter table, I've added another column where I've extracted the selected value of slicer and I am using that column in the top N field but it's not working.Top N Filter Extracted selected value of field parameter

Upvotes: 1

Views: 252

Answers (1)

Ryan
Ryan

Reputation: 2480

pls see if this is what you want

id value category

a   100 AAA
b   200 AAA
c   300 BBB
d   400 BBB
e   500 CCC
f   600 CCC
g   700 AAA
h   800 AAA
i   900 BBB
j   1000    AAA
k   1100    AAA
l   1200    CCC

create a parameter field for id and category for testing.

only select id and top 2 then we filter top 2 id for all data.

Parameter = {
    ("category", NAMEOF('Table'[category]), 0),
    ("id", NAMEOF('Table'[id]), 1)
}


_sum = sum('Table'[value])

MEASURE =
VAR _rank =
    RANKX ( ALL ( 'Table'[id] ), [_sum],, DESC )
RETURN
    IF (
        HASONEFILTER ( 'Table'[id] )
            && SELECTEDVALUE ( 'Table (2)'[Column1] ) = "TOP2",
        IF ( _rank <= 2, 1, 0 ),
        1
    )

then add the measure to filter and set to 1

enter image description here

then we can see all and top 2 work for selection of id

enter image description here enter image description here

when we select category, the top2 does not work enter image description here

Upvotes: 0

Related Questions