Share via

Help me getting distinct count values from an excel column based on the specific value of another column.

Anonymous
2023-02-06T16:24:21+00:00

Hi, I'm new to this community, I'm usually at the power apps one which is very helpful I hope I can find a similar experience on this one as well.

I deal with huge datasets that are generated every day and for one of the tasks i have to manually cross examine data within different datasets and is very tedious process that I believe would be automated some with scripts/macros but after a few days trying different things out I decided to to give the forum a try. For your understanding I uploaded an image (since I know I'm limited trying to explain with words with excel terms). I apologize but for some reason the image upload are failing for me and I couldn't find a proper solution online so I had to host the image instead:

https://tinypic.host/i/excel.i7FNp

So when you look at the image you will see there is a table with five columns an a pivot table to the right. What I want to achieve with the table at the left is that in the "MyFormula" column I could, with a formula, achieve a result similar to the result showing on the "Expectedvalue" column (that I manually inserted the values so you can see what I want). Now the values I want are supposed to be the distinct values of the fruits ("Fruit" column) specifically for the range of the specific retailer ("Retailer" column). For example, since the Retailer 1 has 4 different kind of fruits the expected value for that retailer should be 4 on the Myformula column. Yet the closest Ive managed is to count the unique values for fruit for that specific retailer using the formula [=COUNTIFS(A:A,A2,B:B,B2)] and draggin it down hence the current result you can see in the MyFormula Column.

I've included the pivot table that is the current way we do data work right now but is limited for automation because for me to get the data I have to manually click on the Distinct Count of Fruit value so excel makes a whole new sheet and show me the specific values but that complicates the effort for me to be able to automate things with my current knowledge (which is not much) of excel. I hope I made some sense and sorry for the long explanation. Thank you.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

  1. Ashish Mathur 101.8K Reputation points Volunteer Moderator
    2023-02-06T23:29:01+00:00

    Hi,

    In cell E2, enter this formula and drag down

    =counta(unique(filter($B$2:$B$20,$A$2:$A$20=A2)))

    Hope this helps.

    1 person found this answer helpful.
    0 comments No comments

Answer accepted by question author

  1. Anonymous
    2023-02-06T21:36:40+00:00

    Sorry, it wasn't clear that H:I was a pivot table.

    Try this file.

    1 person found this answer helpful.
    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Anonymous
    2023-02-08T15:25:07+00:00

    Thank you that solved it!

    0 comments No comments
  2. Anonymous
    2023-02-06T20:58:04+00:00

    In I2:

    =COUNTA(UNIQUE(FILTER(B:B,A:A=H2)))

    copied down.

    Maybe i didn't understood the formula but that only works for the Retail1 and requires the pivot data which is not available by default, regardless if you find a way using references with the pivot table i can just build it each time. Thank you for replying. To clarify when i use your formula and drag it down on "Myformula" it only gives the correct (expected) value for the retailer 1 because is referencing only the retailer 1 in the pivot.

    0 comments No comments
  3. Anonymous
    2023-02-06T17:28:03+00:00

    In I2:

    =COUNTA(UNIQUE(FILTER(B:B,A:A=H2)))

    copied down.

    0 comments No comments