Forum Discussion

jakubalbrecht's avatar
2 years ago

Merge URL parameters filters and predefined filters

Hello,

 

1. I can predefine filters in Power BI reports so that readers of the Power BI report in online Power BI service evironment can then filter the report using those filters, they cannot use other data to filter the report. That works fine for me.

 

2. I can also use URL parameters to define the filtering value through URL. That also works fine for me.

 

My trouble is that when I use both options for the same Table/Column (so I set that Table/Column as a predefined filter and in the same time I call the report with URL parameters like https://app.powerbi.com/...&filter=Languages%2FLanguage%20eq%20%27cs%27) those filters do not merge into the single filter but appear as two indepenent filters although they filter the same Table/Column and have the same name:

Please, do you have some hack how to merge both filters into the single one?

 

And one more addition question with much less urgency: Is there any option how to define filter in Power BI desktop, change the filter name different to the original Column name and then use URL parameters to be merged with that renamed filter? E.g.: Original Table/Column name is "Languages/Language" which I use as predefined filter renamed to "Lang". Then I would like to be able to filter report using URL parameters which will be merged with "Lang" filter as the filter the same original Column/Table.

 

Thank you.

 

Jakub

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi jakubalbrecht ,

     

    -- Do you have some hack how to merge both filters into the single one?

    Yes, please refer to an example like this:

    ?filter=Store/Territory in ('NC', 'TN')

    Filter a report using query string parameters in the URL - Filter on more than one value in a field

     

    The second point should not work, you need to use to the original table name and field names.

     

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

  • Hello Anonymous ,

     

    thank you very much but there is still no progress on my side.

     

    https://app.powerbi.com/groups/...../reports/.....&filter=Languages%2FLanguage%20in%20(%27en%27)

     

    still duplicit filter is created - in my original report and ever the same on a brand new report when only a single table Languages has been created with a single column Language to avoid interferencing with other data:

     

     

    I really do not understand why your and mine result is different while sharing the same approach. Power BI URL filtering seems not to be an excellent piece of work by Microsoft.

     

    Any other idea how to solve it?

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi jakubalbrecht ,

       

      Is it possible to consider hard-coding the original filter to the Dax measure? If so, please refer to the following steps:

      1. For the original report, we need to clear the filter on 'Languages' [Language]:

       

      2. then please create a new pbix. here we need a dimLanguages table:

       

      3. then create a new measure like:

       

       

      Report URL = 
      // You need to replace the base url with the actual URL of your own report
      VAR __base_url = "https://app.powerbi.com/groups/5562e085-51a1-4c99-aa4f-6ab2a5351adc/reports/80805289-a9e0-4de2-b4a6-5c34167faa03/"
      // Here we assume the original filter was 'cs' before
      VAR __filter1 = "?filter=Languages/Language in ('cs','"
      VAR __filter2 = CONCATENATEX('DimLanguages','DimLanguages'[Language],"','")
      VAR __result = __base_url & __filter1 & __filter2 & "')"
      RETURN
      __result

       

      Here setting the data category as WebUrl

       

      4. Do some landscaping. Here I'm assuming the original filter was 'cs' and I've hidden the 'cs' option in the slicer. Then created a button and bound the previously created measure. It looks like this now:

       

       

       

      5. Publish. When we select the slicer, the measure automatically generates a link to the report containing the URL filter:


      Clicking the button will automatically jump to the report:

       

      Best Regards,
      Gao

      Community Support Team

       

      If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
      If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

      How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group