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
Krishna1992
Helper I
Helper I

Filter based on criteria

Hello everyone,

 

I have 2 columns in my table, one is category and other is product.

 

I need to select/filter only required category based on product.

 

Something like below table,

ProductCategory
Juicewatermelon
JuicePinapple
Juicepapaya
JuiceApple
soapHamam
soaplifebouy
soapcinthol
powdersandal
powderchintoor
powderponds

 

So my required output is:

ProductCategory
Juicewatermelon
JuicePinapple
soapHamam
soaplifebouy
powdersandal

 

So I only required watermelon and pinapple when product = Juice.

 

Need to filter based on above criteria.

 

Thanks

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

@Krishna1992 

could you do it manually?

go to the Power Query Editor pick your table, add Custom column like

= Text.Combine({[Location], "-", [Category]})

then filter out all you don't need like in Excel

425112.png

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

13 REPLIES 13
adityavighne
Continued Contributor
Continued Contributor

@Krishna1992 

Add filters or Slicer for Product and Category and give multiple selection option.

 

regards,

aditya

Hi @adityavighne ,

 

Thanks for your response..Is it possible to filter it from data itself, instead of visuals?

 

az38
Community Champion
Community Champion

Hi @Krishna1992 

whats scenario should be used? is it predefined filter? are you going to use a slicer?

you could try the simpliest way is to filter in visuals or to create a calculated table

Table = 
FILTER(ALL('Table');
'Table'[Product]="juice" && ('Table'[Category]="watermelon" || 'Table'[Category]="pinapple ")
)

do not hesitate to give a kudo to useful posts and mark solutions as solution

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hi @az38,

Can I filter these data from query editor itself instead of using DAX. I want data to be filtered before projecting in visuals. If I create DAX will that data be applicable for all visuals?

az38
Community Champion
Community Champion

@Krishna1992 

you could easily filter out suceedeed data in Power Query Editor like in Excel

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

I cannot filter in power query because they will not make sense. I will change things up slightly,

 

If we add location column to it. Ex.

LocationProductCategory
IndiaJuicewatermelon
IndiaJuicePinapple
IndiasoapHamam
Indiasoaplifebouy
Indiapowdersandal
USJuicePinapple
USJuicepapaya
USsoaplifebouy
USsoapcinthol
USpowdersandal
USpowderchintoor

 

If I filter category, other location will also filter out, can I do anything in this in query editor. or I need to do DAX?

 

Thanks

 

 

Hi @az38 ,

 

I will remodify the question,

 

Please try if you could try to understand,

 

LocationCategory
Indiawatermelon
IndiaPinapple
Indiapapaya
IndiaApple
IndiaApple
USwatermelon
USPinapple
USpapaya
USApple
USVinegar
USPapaya

 

I need to select category based on location, Eg. India watermelon and pinapple, and for US I only need apple, vinegar.This is requirement. If you could try to through me a solution. Thanks in advance.

az38
Community Champion
Community Champion

@Krishna1992 

lets start step-by-step.

whats your data source? how it looks like? Table "Lcation-Category" is the only data source? How can we define that for India it should be only watermelon and pinapple?

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hi @az38 ,

I need to filter category on different location. Which means Every location may have same category or different category.

But I need to select required category for specific location. Ex. if it is India I need to select certain category, if it is US it need to select certain category.

 

Eg.

India - I need watermelon, apple

US - I need vinegar, watermelon, pinapple.

 

Likewise I need to multiple location. Only DAX is possible or can I do in query editor. Thanks for your response.

az38
Community Champion
Community Champion

@Krishna1992 

how can we understand that for India doesn't need vinegar, for USA - apple? is there a rule or it should be selected by user?

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hi @az38 ,

I was not a rule or selected by user, it was my requirement to select only required category.  User only requires specific category from each category.

az38
Community Champion
Community Champion

@Krishna1992 

could you do it manually?

go to the Power Query Editor pick your table, add Custom column like

= Text.Combine({[Location], "-", [Category]})

then filter out all you don't need like in Excel

425112.png

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
az38
Community Champion
Community Champion

or create a DAX calculated column

=CONCATENATE([Location];[Category])

and filter out in the visual

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

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.