Forum Discussion

PBI5851's avatar
PBI5851
Helper V
5 years ago

Count Days from a Table

Hello,

 I have a requriement to capture how many days a rep is active per month. The rep can have multiple rows in a single day as there are other fields (such as status and categories etc). 

 

JobIDDateRep
J2239/1/2020Mak
J2249/1/2020Steve
J2259/1/2020Shawn
J2269/1/2020Mak
J2279/2/2020Jennifer
J2289/3/2020Shawn
J2299/3/2020Mary
J2309/3/2020Mary
J2319/3/2020Shawn
J2329/5/2020Mal
J2339/5/2020Mak
J2349/5/2020Mak
J2359/5/2020Mak
J2369/5/2020Shawn
J2379/5/2020Steve
J2389/10/2020Jennifer
J2399/10/2020Mary
J2409/10/2020Keith

 

I intend to get the below result

Jennifer2
Keith1
Mak2
Mal1
Mary2
Shawn3
Steve2

Which shows the unique number of days the rep has been active. I was thinking of distinct count of days, but not sure how to count that. When i do a count(date), i get a ridiculously long number. 

 

Any other recommendations on how to achieve this ?

4 Replies

  • Hi,

    Try this.  Drag Rep to the table visual and write this measure

    =distinctcount(data[date])

    Hope this helps.

    • PBI5851's avatar
      PBI5851
      Helper V

      Ashish_Mathur , is there a way to achieve this without displaying the Rep Name. There is a visual need to do a company target and dept target. So i should get 13 for the month and display just that value on a card or subsequent visuals with further calculations. 

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Hi,

        Remove Rep from the visual and change the visual to a card visual.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hello to PBI5851,

    There are two ways to get the effect of your question request:

    1. Create a column

    Month_day =
    CALCULATE(DISTINCTCOUNT('Table'[Date]),ALLEXCEPT('Table','Table'[Rep]))

    Result:

    v-yangliu-msft_0-1602661762232.png

    2. Create a measure and form a card to view it.

    Measure:
    Count = DISTINCTCOUNT('Table'[Date])

    Form a Rep-based cutter and a custom-based Card:

    Result:

    v-yangliu-msft_1-1602661762239.png

    Best regards

    Liu Yang

    If this post helps,then consider Accepting it as the solution to help other members find it faster.