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
Merxvell
Frequent Visitor

Multicolumn Filtering via typescript searchbar.

Edits:

Is there a way to see how something would filter prior to actually filtering the object?
If I'm able to do that then I can make it a logic where if blank / no values go to the next item to check.

 

 

Original Post:

 

Hi right now I'm submitting the following search query via typescript utilizing the ITupleFilter action (which may be incorrect? not sure) in order to try and do one of two things...

  1. Find things that match in both columns of the data (EX: column: street value: 1234 lane .... column: zip value: 12345)
  2. Find data that matches in one column of the data provided to the search bar (ex only 1234 lane appears and there's no zip code that starts with 1 in the dataset.)

Right now I'm gathering the data I need (column and table values) via the following loops

 

 

//This is in the public update(options: VisualUpdateOptions)function
const array = []
    options.dataViews[0].metadata.columns.forEach(element => {
      array.push(element)
    });

    this.myArray = array


// This portion is in a public performSearch(text: string) function
let testTarget: ITupleFilterTarget = []

this.myArray.forEach(element => {
      if (element) {
        testTarget.push({
          table: element.queryName.substr(0, element.queryName.indexOf(".")),
          column: element.queryName.substr(element.queryName.indexOf(".") + 1)
        })
      }
    });

 

 

 

and putting it into a tuplefilter as such.

 

 

    const isBlank = ((text || "") + "").match(/^\s*$/);
    let filter: ITupleFilter = null;
    let action = FilterAction.remove;
    if (!isBlank) {
      filter = {
        $schema: "https://powerbi.com/product/schema#Tuple",
        filterType: 6, //wtf??? FilterType.Tuple?? if this **bleep** works idfk man just.... https://community.powerbi.com/t5/Custom-Visuals-Development/Custom-Search-Visual/m-p/663749
        operator: "In",
        target: testTarget,
        values: [[{value: text}]]
      }
      console.log("filter")
      console.log(filter)
      action = FilterAction.merge;

    }

    
    this.host.applyJsonFilter(filter, "general", "filter", action)

    this.searchBox.property("value", text);

 

 

 

I'm noticing that if I have two data fields I can search the first but not the second.

 

Also there isn't a way to do this the "contains" operator is there?

 

Base of the code was provided from this repository https://github.com/microsoft/PowerBI-visuals-TextFilter/blob/master/src/visual.ts

thanks.

2 ACCEPTED SOLUTIONS

I found a way of doing it and will post the code on github. While it doesn't filter two columns at once it does allow me to filter based on the highest potential quantity of matches for the string of text against all column (so far just Int and string but this has worked for dates and hybrid text [v123]). 

View solution in original post

Sure thing, haven't figured out how to approach trying to get this merged into microsofts main branch.

Please let me know if you find any bugs.

https://github.com/gmmeyers/PowerBI-visuals-TextFilter

 

release to just upload to powerbi here. 
https://github.com/gmmeyers/PowerBI-visuals-TextFilter/releases/tag/1.0.0

View solution in original post

5 REPLIES 5
Ledia
Frequent Visitor

Hey @Merxvell, I am having the same filtering issue. Could you possibly share your github repository so I can see your approach?

Thanks.

Sure thing, haven't figured out how to approach trying to get this merged into microsofts main branch.

Please let me know if you find any bugs.

https://github.com/gmmeyers/PowerBI-visuals-TextFilter

 

release to just upload to powerbi here. 
https://github.com/gmmeyers/PowerBI-visuals-TextFilter/releases/tag/1.0.0

v-yiruan-msft
Community Support
Community Support

Hi @Merxvell ,

Do you want to filter data from multiple fields at a time? Generally, a custom visual like Text Filter can only filter one field. Please check the link below to see if it can be an alternative solution to achieve your needs.

1. Create a calculated table and measure:

How to filter on multiple columns (check the post from Vvelarde )

2. Create hierarchy slicer:

Create filter from two columnsyingyinr_0-1653965418244.png

Power bi slicer multiple columns with examples

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

My wording was pretty trash after re-reading it. Ideally I'd like something like this in terms of step order (which I think I'm getting close to?)

  1. search column A based on the text field
  2. if filter shows not / there is a matching value, grab results
  3. Else, search column B based on the text field
  4. repeat

I realized a tuplefilter was not what I needed but rather Advance filter. I'm close I just need to know how to see if the filter would return empty. 

I found a way of doing it and will post the code on github. While it doesn't filter two columns at once it does allow me to filter based on the highest potential quantity of matches for the string of text against all column (so far just Int and string but this has worked for dates and hybrid text [v123]). 

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Solution Authors