Distinct count of Agent with comparing Date and Program

I have Module in DataHub without any Dimension 
I need to create a column that count distinct (Unique) Value of Agent
Program and Agent are in Text Format 

 

DateProgram Agent Distinct Agent count
01-01-221213
01-01-22122 
01-01-22123 
01-01-222213
01-01-22222 
01-01-22227 
01-01-223214
01-01-22322 
01-01-22335 
01-01-22346 
02-01-221212
02-01-22124 
02-01-222291
02-01-22229 
02-01-223521

Best Answer

  • ManjunathKN
    edited November 2022 Answer ✓

    @HarishBabu 

     

    you have asked for distinct count and not count.

    if agent are repeated it should give 1 count for each agent.

    ManjunathKN_0-1667572232326.png

     

    if you want agent count then use this rank logic.

    RANK(Program, ASCENDING, MAXIMUM, TRUE, Group By)

     

    Thanks,
    Manjuanth

Answers

  • ManjunathKN
    edited November 2022

    Hi @HarishBabu,

     

    How you can have so many rows without any dimensions?

     

    I think it might have Day as dimension.

     

    Thanks,

    Manjunath

  • ShubhamCh
    edited November 2022

    Hi @ManjunathKN 

    I think this is a transactional module over a transactional list which has IDs. Usually Data hubs have transactional modules. I believe @HarishBabu  has ignored that left most column which shows the IDs. That's my understanding of the problem. My assumptions might be wrong.

    Thanks!

    -Shubham

  • ManjunathKN
    edited November 2022

    Hi @ShubhamCh 

     

    yes, might be. However, this can be solved by rank and isfirstoccurance.

     

    Thanks,
    Manjunath

     

  • HarishBabu
    edited November 2022
    There was a list created with Concat(Date,Program,agent), which is not good practice to have But following that method because it was already built in my Project.
  • HarishBabu
    edited November 2022

    Thanks for your replies.

    Hi @ManjunathKN , 
    Rank function is for Number, Program and Agent are in Text Format

    Isfirstoccurrence require list

    Requirement - Filter Date, Filter Program, Count(Distinct(Agent))

  • ManjunathKN
    edited November 2022

    Hi @HarishBabu 

     

    you need to use your concat list for this, without list you cannot have different rows in anaplan if your line item is in columns and vice versa. if you have different format use the data type conversion ex: Value() function.

     

    Let me know if below solution works for you.

     

    ManjunathKN_0-1667558898700.png

    Blueprint View

    ManjunathKN_2-1667558987574.png

    Logics

    IF Isfirstoccurance THEN RANK(Agent, DESCENDING, SEQUENTIAL, TRUE, Group By) ELSE 0
    TEXT(Program) & "|" & TEXT(MONTH(Date)) & "/" & TEXT(DAY(Date)) & "/" & TEXT(YEAR(Date))
    ISFIRSTOCCURRENCE(Group By, 'Test List L1')

     

    I prefer to do this in spoke model.

     

    Thanks,
    Manjunath

  • ManjunathKN
    edited November 2022

    Hi @rob_marshall,

     

    Need your advise,

     

    Where do we have to do this, is it okay to do this datahub or in spoke by brining the transactional list. Since it has few text functions

     

    Thanks,
    Manjunath

  • HarishBabu
    edited November 2022

    First of all Big Thanks for your efforts @ManjunathKN 
    As per this formula i expect the count of Distinct Agent which is 25 but here it's showing 15 
    Not able to figure out why?

    HarishBabu_0-1667570057357.png

     



    Thanks,

    HarishBabu

     

     

  • ManjunathKN
    edited November 2022

    @HarishBabu 

     

    that difference 10 is agent columns not assigned i believe. Which means that only 15 agents might have provided and in other 10 cells agents are not assigned or blank.

     

    Thanks,
    Manjunath

  • ManjunathKN
    edited November 2022

    @HarishBabu  do you have alphabetical character in your agent ID?.

     

     

  • HarishBabu
    edited November 2022

    No 
    Only Number because Source of Agent ID is text so maintaining here as Text 
    No Alphabetical characters

  • HarishBabu
    edited November 2022
    Yes, Requirement is Distinct Count only. But all 25 Agents are different.

    I tried with Maximin also still showing same.

    Thanks,
    HarishBabu
  • ManjunathKN
    edited November 2022

    I could see some are same here.

    cannot figure out since, it is hidden.

    ManjunathKN_0-1667572926192.png

     

    Thanks,
    Manjunath

     

  • HarishBabu
    edited November 2022

    Hi @ManjunathKN ,
    Little confusion because of sorting. After ranking by Program the value is matching.

    Thanks a lot.

     

    Thanks,

    HarishBabu