Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
camilocorralesg
Advocate I
Advocate I

Filter with a dynamic value a virtual table

Hi everybody, I'm trying to Filter a virtual table by Ranking position, the number of positions visualized by the users are chosen from a slicer generated from a What-if parameter. This is my Dax expression:

var agentss = SUMMARIZE(ALL(fct_hotel_revenue),[agent],"__Rank",[Rank], "Income", [Income])
var agentss___ = SELECTCOLUMNS(FILTER(agentss, [__Rank] <= 20), "agent", [agent])
var filterss = FILTER(fct_hotel_revenue, fct_hotel_revenue[agent] IN agentss___)
RETURN
CALCULATE([Income], filterss)
 
Instead of FILTER(agentss, [__Rank] <= 20 I would like to be the dynamic value corresponding to the selected value in the slicer, but when I try it FILTER(agentss, [__Rank] <= SELECTEDVALUE(Ranking[Ranking]) I get blank as a result, how can I fix this?
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@camilocorralesg , hope Ranking is an independent table with set on number to filter, else use what if parameter

https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-what-if

 

small change

var agentss = filter(SUMMARIZE(ALL(fct_hotel_revenue),[agent],"__Rank",[Rank], "Income", [Income]), [__Rank] <= <= SELECTEDVALUE(Ranking[Ranking])  )
var agentss___ = SELECTCOLUMNS(agentss, "agent", [agent])
var filterss =
RETURN
CALCULATE([Income], FILTER(fct_hotel_revenue, fct_hotel_revenue[agent] IN agentss___))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
camilocorralesg
Advocate I
Advocate I

Thanks!

 

amitchandak
Super User
Super User

@camilocorralesg , hope Ranking is an independent table with set on number to filter, else use what if parameter

https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-what-if

 

small change

var agentss = filter(SUMMARIZE(ALL(fct_hotel_revenue),[agent],"__Rank",[Rank], "Income", [Income]), [__Rank] <= <= SELECTEDVALUE(Ranking[Ranking])  )
var agentss___ = SELECTCOLUMNS(agentss, "agent", [agent])
var filterss =
RETURN
CALCULATE([Income], FILTER(fct_hotel_revenue, fct_hotel_revenue[agent] IN agentss___))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.