logo elektroda
logo elektroda
X
logo elektroda

[Solved] Excel: Count Women in Two-Part City Names using Nested Functions (Countif, Find, Text Fragment)

twardenka 19323 6
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 16057585
    twardenka
    Level 6  
    Hi,

    In the attached table I have data on, among others cities and heads of regions.
    I have to use nested functions (without the use of auxiliary columns) to extract data on the number of women from cities with a two-part name (Bielsko-Biała, Biala Podlaska, etc.)

    Unfortunately, I was stuck on the 'woman' condition. I can't combine the count.if function with a fragment.text, even though its "find" components; "text fragment" work properly (ie they return me names ending in a, meaning women). However, I have a problem with counting them. "countif" returns zero to me.
    = COUNTIF (G3: G54, FRAGMENT.EXT (G3: G54, FIND (""; G3: G54) -1, 1) = "a")

    Do you have any idea how to solve it?

    (G3: G54 is the search range - column with the names and surnames of the heads of the regions)
    Thanks in advance for your help.
  • ADVERTISEMENT
  • Helpful post
    #2 16057796
    Prot
    Level 38  
    twardenka wrote:

    = COUNTIF (G3: G54, FRAGMENT.EXT (G3: G54, FIND (""; G3: G54) -1, 1) = "a")

    Do you have any idea how to solve it?


    It is too late time to practice such wobbles. But analyze slowly the inner functions (TextSnippet () and Find ()). Do they really work with arrays as an argument :?: If this were the case, how many occurrences of this condition would be indicated in the result and how would the array be placed in one cell? :D

    I used to make such expressions without an additional column, but then I created a variable name (here, for example, a woman) which, depending on the line number, defined the state of this variable (true-false).
    Then it was enough to count how many times in a given array the variable takes a certain state, e.g. COUNTIF (Array; Woman = True). :idea:
  • ADVERTISEMENT
  • Helpful post
    #3 16057950
    JRV
    VBA, Excel specialist
    what about that?
    = COUNTIF (G3: G54; "* a *")
  • ADVERTISEMENT
  • #4 16058185
    twardenka
    Level 6  
    Prot, I guess you were right that it was not the time for such a freak :)
    Of course, I only checked the function of find and fragment.text for a single line, not for an array, and only then it worked for me.
    Thanks.

    JRV, thanks a lot !! Simple and perfect :)
    I am therefore left with the second condition, i.e. two-part cities.
    Combining these conditions in the count conditions function will be ok?
    I suppose I could check which city names contain "-" (Bielsko-Biała) OR "" (Biała Podlaska), I understand correctly?
    The assumption in the task is that I cannot use these city names, but I have to check which of them are binary.
  • Helpful post
    #5 16058311
    JRV
    VBA, Excel specialist
    = COUNTIF (C3: C54, "* *") + COUNTIF (C3: C54; "* - *")
  • #6 16058332
    twardenka
    Level 6  
    Thank you.
    Ultimately, I put it together like this:
    = COUNTIFS (G3: G54; "* a *"; C3: C54; "* *") + COUNTIFS (G3: G54; "* a *"; C3: C54; "* - *")
  • ADVERTISEMENT
  • #7 17362437
    twardenka
    Level 6  
    = COUNTIFS (G3: G54; "* a *"; C3: C54; "* *") + COUNTIFS (G3: G54; "* a *"; C3: C54; "* - *")

Topic summary

The discussion revolves around using nested Excel functions to count the number of women associated with two-part city names in a dataset. The user initially struggled with combining the COUNTIF function with TEXTFRAGMENT to filter names ending in "a". Responses suggested using simpler COUNTIF expressions, such as COUNTIF(G3:G54, "* a *"), which successfully counted names. The user later combined conditions for two-part city names using COUNTIFS, resulting in the formula: =COUNTIFS(G3:G54, "* a *", C3:C54, "* *") + COUNTIFS(G3:G54, "* a *", C3:C54, "* - *"). This approach effectively counts women from cities with two-part names.
Summary generated by the language model.
ADVERTISEMENT