Forum Discussion

MMAKSATULY's avatar
MMAKSATULY
Regular Visitor
3 years ago
Solved

Filtering a table by one of its columns

Hi everyone. 

I could not find such a problem on the forum or on the Internet (there are similar problems but there are two or more source tables).

I need any help to filter the source table. In the source table there is a product category and each product has its own key. I would like to filter the source table so that only those products that match the product key with category C remain there. Now I filter separately category C into the table. And then, through the merge, I sort the source into categories A and B. But I can’t combine it all into one table back because of the loop.

I would like all three categories to be in one table and only the same keys as category C products.

Please tell me if it is possible to implement this in power query without cycling error? 

Please see the attachment.  https://drive.google.com/drive/folders/1kmHK3V9MkjHEfyqa7Za8v_G1vXbf4IOK?usp=sharing  Change the location of the excel file in the "filename" parameter.  

RegionProductStoreCategoryPriceNeedDistributionProduct on the wayMonthkey
SD8966012183520A561,4801 01.08.223520896601218
SD8966012243520A214,1701 01.08.223520896601224
SD8966012253520A121,2801 01.08.223520896601225
UU701003191205C1,5911 01.08.22120570100319
UU1101013101205C11,6511 01.08.221205110101310
UU1103010171205C19,5711 01.08.221205110301017
KN304071653510B0,7311 01.10.22351030407165
KN710050233510B21,0711 01.12.22351071005023
KN1100010693510B1,4111 01.11.223510110001069
  • =let a=Table.SelectRows(PreviousStepName,each [Category]="C"), b=List.Buffer(a[key]) in a&Table.SelectRows(PreviousStepName,each List.Contains(b,[key]))

2 Replies

  • wdx223_Daniel's avatar
    wdx223_Daniel
    Icon for Community Champion rankCommunity Champion

    =let a=Table.SelectRows(PreviousStepName,each [Category]="C"), b=List.Buffer(a[key]) in a&Table.SelectRows(PreviousStepName,each List.Contains(b,[key]))

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,

     

     Not sure I follow are you looking to fitler on 2 seperate criteria at the same time? i.e.

    = Table.SelectRows(#"Changed Type", each ([Product Code] = 123) and ([Category] = "C"))

     

    This would show you any line where Product Code = 123 but only if Category = C

    If thats not right can you give example of what you are trying to achieve/expect to see.

     

    Thanks,