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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
captainlaw
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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