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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
captainlaw
Microsoft Employee
Microsoft Employee

Chart Filter Using a Variable?

Hello,

I'm wondering for chart filter, is it possible to use a variable?  Right now, I have to hard-code a number. 

Appreciated!

1 ACCEPTED SOLUTION

ok, now i understand. I was able to do this in excel 2013 with the old power query and powerpivot where by you fiddled  with a piece of M code and could write back a variable from the spreadsheet into the datamodel. I will try and track it down but have had no luck so far. I bet you can still do it in powerbi given that its all the same - it will involve passing back value from an unrelated table. Sorry i dont have a solution at hand.

// if this is a solution please mark as such. Kudos always appreciated.

View solution in original post

12 REPLIES 12
oalgarvio
Frequent Visitor

Have you found a solution? I'm struggling with the same problem. I managed to use a parameter to filter measures displayed in cards but not charts

ankitpatira
Community Champion
Community Champion

@captainlaw On top of what @samdthompson requested, i am guessing you're referring to paramter that can be passed to filter in a report. If yes then in power bi service you can't access parameters that you create in power bi desktop yet but there is a way to programatically pass filter values to a report in power bi.

 

Report URL looks like 

 

https://app.powerbi.com/groups/me/reports/7fe9a5d0-adff-4e98-bad0-dd77d64ce836/ReportSection

 

You can specify filter values to report url as described in this post.

Hello Ankit,

I'm actually trying to accomplish parameter/variable in desktop not the service.  Is that possible?  If so, is there a blog describing how to accomplish that?

 

Appreciated!

Assuming that you are wanting a static > 5 for example, can you do something like this.... =calculate([measure],filter(table,table[measure]>5)). Is that what you are looking for?

// if this is a solution please mark as such. Kudos always appreciated.

Dynamic filtering is what I'm looking for. 

I don't think the dropdown filter selection box allows me to enter code.  Let me know if my assumption is incorrect. 

I also tried Parameter, but with no avail. 

Its a measure to write. Go to modelling on the menu and then to new measure. If LAWRank is not a defined measure already it might need to be something like:

 

=calculate(sum[table[LAWrank],filter(table,table[m​easure]>5))

// if this is a solution please mark as such. Kudos always appreciated.

The goal is to make it dynamic so without hardcoding but allow user selection.

ok, now i understand. I was able to do this in excel 2013 with the old power query and powerpivot where by you fiddled  with a piece of M code and could write back a variable from the spreadsheet into the datamodel. I will try and track it down but have had no luck so far. I bet you can still do it in powerbi given that its all the same - it will involve passing back value from an unrelated table. Sorry i dont have a solution at hand.

// if this is a solution please mark as such. Kudos always appreciated.

How is this dynamic?

samdthompson
Memorable Member
Memorable Member

Hi can you please explain a little more on what you mean by filtering with a variable and where you hard code anything.

// if this is a solution please mark as such. Kudos always appreciated.

Yes.  I've attached a screenshot of the chart filter.  I hard-coded the field to only <= 5  Would love to apply variable to replace 5.  pbi-filter.JPG

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

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