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
Anonymous
Not applicable

Question on sub filters

Hi I need some hep with the following:

 

Here's my sample data 

 

NameCountryLevel

CarolAustraliaExe 1
JeremyIrelandExe 1
RachelItalyExe 1
Colin JapanExe 1
KelvinAustraliaManager 1
TomIrelandManager 1
EmmaItalyManager 1
TerenceJapanManager 1
TimAustraliaManager 2
ChristopherIrelandManager 2
AileenItalyManager 2
Lucas JapanManager 2
JustinAustraliaManager 3
EricIrelandManager 3
RandallItalyManager 3
StuartJapanManager 3
PearlAustraliaSenior Leader 1 
SarahIrelandSenior Leader 1 
Howard ItalySenior Leader 1 
Dorothy JapanSenior Leader 1 
JanAustraliaExe 2
TammyIrelandExe 2
JonItalyExe 2
LandoJapan

Exe 2

 

Question 1

1. I would like to filter and exclude across 2 fields. Specifically, I would like to remove people based in Japan who are not Leaders. How would I do that?

 

2. I only need Leaders + Mangers in my data set, so what I've done is to filter by level and remove the Exes. Though I do need to include a small number of Exes whom I am able to identify by name. So in the data above, how would I remove all exes, but keep only Jeremy and Lando?

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

You can use similar formulas in power query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZJNTsMwFISvUnndDfQEValEQyoh0l3UxSh5wpb8U704QG7DWTgZLg4QW+7Oet9YM2/sthU7sNNiLbbj4BlaIZz3H7S6E+d1KypiMlMYHZg0bJ/AF3SSrncPHnpK0M5pZb8+w6zCBTZhT6TflM0sj7B4JZ4lJ2cSz5TujcHCNbsaEtuOFs4ZV+aG9X1MLlkN3l0kcTFCVG2VJrKFEBHXY4chWT/lVbC/WcEmLsmqKwbYzN3bHloXEkTe+BHsCwEifiZw/uoNWeV4VRP6v7YaMGQSo6R6dO/g/mff3zQl2YNj5+WU9FLSVciruX6e2NwJpvAf51bd8kX+53UQuuwrBnL+Bg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Country = _t, Level = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Country", type text}, {"Level", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Country] ="Japan" and [Level] <> "Senior Leader 1"
then 1 else 0),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each [Level] <> "Exe 1" and [Level] <> "Exe 2" and [Custom] <> 1 or [Name] = "Lando" or [Name] = "Jeremy"),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Custom"})
in
    #"Removed Columns"

V-lianl-msft_0-1623139481141.png

 

View solution in original post

3 REPLIES 3
V-lianl-msft
Community Support
Community Support

You can use similar formulas in power query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZJNTsMwFISvUnndDfQEValEQyoh0l3UxSh5wpb8U704QG7DWTgZLg4QW+7Oet9YM2/sthU7sNNiLbbj4BlaIZz3H7S6E+d1KypiMlMYHZg0bJ/AF3SSrncPHnpK0M5pZb8+w6zCBTZhT6TflM0sj7B4JZ4lJ2cSz5TujcHCNbsaEtuOFs4ZV+aG9X1MLlkN3l0kcTFCVG2VJrKFEBHXY4chWT/lVbC/WcEmLsmqKwbYzN3bHloXEkTe+BHsCwEifiZw/uoNWeV4VRP6v7YaMGQSo6R6dO/g/mff3zQl2YNj5+WU9FLSVciruX6e2NwJpvAf51bd8kX+53UQuuwrBnL+Bg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Country = _t, Level = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Country", type text}, {"Level", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Country] ="Japan" and [Level] <> "Senior Leader 1"
then 1 else 0),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each [Level] <> "Exe 1" and [Level] <> "Exe 2" and [Custom] <> 1 or [Name] = "Lando" or [Name] = "Jeremy"),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Custom"})
in
    #"Removed Columns"

V-lianl-msft_0-1623139481141.png

 

amitchandak
Super User
Super User

@Anonymous , Try measures like these measures

 

calculate(countrows(Table), filter(table, not(Table[Country] ="Japan" && search("Leader",[Level],,0) =0)))

 

 

calculate(countrows(Table), filter(table, search("Exe",[Level],,0) >0 || search("Manager",[Level],,0) >0 || [Name] in {"Jeremy","Lando"} ))

Anonymous
Not applicable

Thanks Amit,

 

I'm trying to work through the first solution. Can you explain the last part (in bold) in detail?

 

calculate(countrows(Table), filter(table, not(Table[Country] ="Japan" && search("Leader",[Level],,0) =0)))

 

My interpretation of this part is to exlude all in Japan, except the title leader. Is that correct?  My data has leader 1, leader 2, leader 3 and so on. Does that mean in the formula above I need to include all the leaders that I want to keep, or specific all that I want to exclude? Could you please share an updated Measure formula so I can slowly analyse it? 

 

Thanks!

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.