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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
ageuffrard
Frequent Visitor

Show all the data when filter is empty

Hi everyone, 

I created filters (Region, Operator defined by "or" and "and", and Source) where users can choose manually and when I press the actualisation button its shows the filtered data on the right, like this : 

ageuffrard_0-1651565530763.png

When the Operator filter (in orange in the pic) is empty, I want it to show all the data without filters (got 30 lines in total), but I can't find the way to do it.

Here's my Power Query code : 

let

  // ajout des paramètres de filtre                                                                                                                                                                                                                                       
  filtreRegion = f_Region,
  filtreSource = f_Source,
  filtreOperateur = f_Operateur,

  Source = Excel.CurrentWorkbook(){[Name = "tbl_region_source"]}[Content],
  #"Filtered lines" = Table.SelectRows(
    Source,
    each
      if f_Operateur = "or" then
        (([Région] = f_Region) or ([Source] = f_Source))
      else
        (([Région] = f_Region) and ([Source] = f_Source))
      // else if f_Operateur = "" then
      // Source
  ),
  removingDuplicate = Table.Distinct(#"Filtered lines")
in
  removingDuplicate

 

Thanks for the help !

 

Alexandre

1 ACCEPTED SOLUTION
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Assuming that there is one column which contains non blank values. Let's assume this column is Region (Looks like your Numero client is one such column). Then you can use following code

 

let

  // ajout des paramètres de filtre                                                                                                                                                                                                                                       
  filtreRegion = f_Region,
  filtreSource = f_Source,
  filtreOperateur = f_Operateur,

  Source = Excel.CurrentWorkbook(){[Name = "tbl_region_source"]}[Content],
  #"Filtered lines" = Table.SelectRows(
    Source,
    each
      if f_Operateur = "or" then
        [Région] = f_Region or [Source] = f_Source
      else if f_Operateur = "and" then
        [Région] = f_Region and [Source] = f_Source
      else [Région]<>""
  ),
  removingDuplicate = Table.Distinct(#"Filtered lines")
in
  removingDuplicate

 

Now' let's assume that there is no such column. In this case, you can insert one Index column. Index column is always non blank and replace [Région]<>"" with [Index]<>""

Then you can remove the Index column after this step.

View solution in original post

4 REPLIES 4
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Following should work

let

  // ajout des paramètres de filtre                                                                                                                                                                                                                                       
  filtreRegion = f_Region,
  filtreSource = f_Source,
  filtreOperateur = f_Operateur,

  Source = Excel.CurrentWorkbook(){[Name = "tbl_region_source"]}[Content],
  #"Filtered lines" = Table.SelectRows(
    Source,
    each
      if f_Operateur = "or" then
        [Région] = f_Region or [Source] = f_Source
      else if f_Operateur = "and" then
        [Région] = f_Region and [Source] = f_Source
      else Source
  ),
  removingDuplicate = Table.Distinct(#"Filtered lines")
in
  removingDuplicate

Told me : "We cannot convert a value of type Table to type Logical".

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Assuming that there is one column which contains non blank values. Let's assume this column is Region (Looks like your Numero client is one such column). Then you can use following code

 

let

  // ajout des paramètres de filtre                                                                                                                                                                                                                                       
  filtreRegion = f_Region,
  filtreSource = f_Source,
  filtreOperateur = f_Operateur,

  Source = Excel.CurrentWorkbook(){[Name = "tbl_region_source"]}[Content],
  #"Filtered lines" = Table.SelectRows(
    Source,
    each
      if f_Operateur = "or" then
        [Région] = f_Region or [Source] = f_Source
      else if f_Operateur = "and" then
        [Région] = f_Region and [Source] = f_Source
      else [Région]<>""
  ),
  removingDuplicate = Table.Distinct(#"Filtered lines")
in
  removingDuplicate

 

Now' let's assume that there is no such column. In this case, you can insert one Index column. Index column is always non blank and replace [Région]<>"" with [Index]<>""

Then you can remove the Index column after this step.

It works perfectly with the [Région]<>"" method.

And I understand your approach concerning the no-column case, I'll keep that in mind in case it happens.

Thank you very much for your time, your services and the tip. Please have a nice day.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.