Count Stints for Employees - DAX Challenge

แชร์
ฝัง

ความคิดเห็น • 24

  • @vijayakumarsrinivasan787
    @vijayakumarsrinivasan787 2 ปีที่แล้ว

    Chandeep Ji thanks for your all videos, especially dax challenges, I idid this challenge by following steps
    1. Create Index column in power query
    2. Create a calculate column as 'Previous value = CALCULATE(MAX(Data[Role]), FILTER(Data, Data[Index]=EARLIER(Data[Index])-1))'
    3. Create another calculate column as 'Stint Count = CALCULATE(COUNT(Data[Index]),IF(Data[Role] Data[Previous value],1))'

  • @wayneedmondson1065
    @wayneedmondson1065 2 ปีที่แล้ว

    Hi Chandeep. Great challenge! Will have to think about this one.. looking forward to the solutions. Thumbs up!!

  • @terpstry
    @terpstry 2 ปีที่แล้ว +3

    Hi Chandeep,
    First I added an index column to the table.
    Next I added a calculated column named [Stints].
    Stints =
    IF(
    Data[Role]=LOOKUPVALUE(Data[Role],Data[Index],Data[Index]-1),
    0,
    1
    )
    I can then put EmpCode and Stints in a matrix and Sum the values in the Stints column.
    This gives me the exact number of stints.
    Regards,
    Ytzen

    • @nithinkumar6734
      @nithinkumar6734 2 ปีที่แล้ว

      why there is Data[index]-1 in the above formula can you explain?

    • @terpstry
      @terpstry 2 ปีที่แล้ว

      @@nithinkumar6734 the Data[Index] contains the row number . Data[Index]-1 selects the previous row. If the present role (stint) is different from the previous stint then it’s a new stint so therefore I count 1.

    • @nithinkumar6734
      @nithinkumar6734 2 ปีที่แล้ว

      @@terpstry so whenever there is a role change its return 1 right . Great logic

    • @terpstry
      @terpstry 2 ปีที่แล้ว

      @@nithinkumar6734 That’s right. This approach produces the right number of stints.

    • @shaikmba3279
      @shaikmba3279 2 ปีที่แล้ว +1

      If we did like this see the Employee
      id EMPC 616 It comes 0 but in Data he's a Regional manager

  • @subhadipsur7561
    @subhadipsur7561 2 ปีที่แล้ว

    Number of roles = COUNTROWS(DISTINCT(Data[Role]))

  • @Sh-wo2fg
    @Sh-wo2fg 2 ปีที่แล้ว

    Hi Chandeep,
    Thanks a lot for your perfect Powerbi tutorials.
    I think one of the solutions for solving this challenge is to create a measure with this formula:
    NumberOfEmployeeRoles = SUMX(SUMMARIZE(data,Data[EmpCode],Data[Role],"Role Distinct Count",DISTINCTCOUNT(Data[Role])),[Role Distinct Count])
    It works for me. Please give feedback.

  • @PowerMacro
    @PowerMacro ปีที่แล้ว

    Chandeep, Thanks a million

  • @mahathmasadineni2884
    @mahathmasadineni2884 2 ปีที่แล้ว

    Hi chandeep. I had a similar case where I need to find the renewals.

  • @mahathmasadineni2884
    @mahathmasadineni2884 2 ปีที่แล้ว

    I had this interesting question. How can we create self join for a table after applying filters...
    Synario :
    I have a customers data base who have start date and end date based on agreement. Some arguments will valid for 1 years. Some arguments will valid for more than a year....
    Q1) in each month or quarter how many customers are expiring( based on end date will check how many expiring)..
    Q1) how many partners are came after they got expired (start date should be after the end date of expired one)....

  • @narendrababu2287
    @narendrababu2287 2 ปีที่แล้ว

    Countrows(filter(employee stints, earlier(employeestints[Role]=employeestints[Role])))
    I think this might work...

    • @GoodlyChandeep
      @GoodlyChandeep  2 ปีที่แล้ว

      If this is a measure.. the earlier won't work this way.

    • @narendrababu2287
      @narendrababu2287 2 ปีที่แล้ว

      @@GoodlyChandeep okay... Tq

  • @rajeshvarre7412
    @rajeshvarre7412 2 ปีที่แล้ว

    Hi I am new to power bi don't know if this is what u said but I tried:
    stints = CALCULATE( DISTINCTCOUNT(Data[Role]))
    Can someone say if I am right or wrong?

    • @brianjulius6401
      @brianjulius6401 2 ปีที่แล้ว

      That's a good thought, and would work if each employee could only do a role one time. However if you look at employee 105782 for example, they jump back and forth between Branch Manager and Team Supervisor. Doing a distinct count of roles by employee misses their second stint in each of those roles, and returns a value of 3 rather than the correct value of 5.

    • @rajeshvarre7412
      @rajeshvarre7412 2 ปีที่แล้ว +1

      @@brianjulius6401 Thanks for the response man. Trying to find a solution with the knowledge I have.

  • @nithinkumar4155
    @nithinkumar4155 2 ปีที่แล้ว

    hello chandeep can it be solved only using dax or we can use power query

  • @guojieyang497
    @guojieyang497 2 ปีที่แล้ว

    Summarize then count, easier