Forum Discussion

Powerful's avatar
Powerful
Frequent Visitor
4 years ago
Solved

Released and Joined Employees count

Hi,

I'm new to PowerBI DAX. I have connected data source to a folder where list of employees data dump is placed on regular basis (not daily).  Table name called Emp Data, columns are Data Dump Date, Emp ID, Emp Name and so on. I have created calendar table already in data model.

After appending different data files from folder it looks like as below:

 

Data Dump DateEmp IDEmp NameProject Code
3/14/202212345RameshABC123
3/14/202254321SureshXYZ123
3/14/202211223MaheshABC123
3/14/202212342GaneshXYZ123
3/14/202290876KailashABC123
3/14/202284782PawanABC123
3/14/202224729GirishXYZ123

3/17/2022

12345RameshABC123
3/17/202254321SureshXYZ123
3/17/202211223MaheshABC123
3/17/202212342GaneshXYZ123
3/17/202290876KailashABC123
3/17/202223432TinuABC123
3/17/202263325MinuXYZ123
3/17/202225266RituABC123

I'm trying to create a measure to find out count of employees released and joined in the next date.

Result should look like this:

3/14/2022ReleasedJoined3/17/2022
7238

Released: 2 as Emp ID 84782, 24729 are missing in the next date.

similarly Joined: 3 as Emp ID 23432,63325,25266 were not there in the previous date.

 

Appreciate any help in this.

Thanks.

  • Hi, Powerful 

     

    You can try the following methods.

    Measure:

    Count1 = 
    CALCULATE (
        COUNT ( 'Table'[Emp ID] ),
        FILTER (
            ALL ( 'Table' ),
            [Emp ID] = SELECTEDVALUE ( 'Table'[Emp ID] )
                && [Data Dump Date] <= SELECTEDVALUE ( 'Table'[Data Dump Date] )
        )
    )
    Count2 = 
    CALCULATE (
        COUNT ( 'Table'[Emp ID] ),
        FILTER (
            ALL ( 'Table' ),
            [Emp ID] = SELECTEDVALUE ( 'Table'[Emp ID] )
                && [Data Dump Date] >= SELECTEDVALUE ( 'Table'[Data Dump Date] )
        )
    )
    Joined = 
    CALCULATE (
        COUNT ( 'Table'[Emp ID] ),
        FILTER (
            ALL ( 'Table' ),
            [Data Dump Date] = MAX ( 'Table'[Data Dump Date] )
                && [Count1] = 1
        )
    )
    Released = 
    CALCULATE (
        COUNT ( 'Table'[Emp ID] ),
        FILTER (
            ALL ( 'Table' ),
            [Data Dump Date] = MIN ( 'Table'[Data Dump Date] )
                && [Count2] = 1
        )
    )

    Is this the result you expect?

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

5 Replies

    • Powerful's avatar
      Powerful
      Frequent Visitor

      Thanks Phil,

      I added few more details with sample data.

      Please help!

  • v-zhangti's avatar
    v-zhangti
    Icon for Community Support rankCommunity Support

    Hi, Powerful 

     

    You can try the following methods.

    Measure:

    Count1 = 
    CALCULATE (
        COUNT ( 'Table'[Emp ID] ),
        FILTER (
            ALL ( 'Table' ),
            [Emp ID] = SELECTEDVALUE ( 'Table'[Emp ID] )
                && [Data Dump Date] <= SELECTEDVALUE ( 'Table'[Data Dump Date] )
        )
    )
    Count2 = 
    CALCULATE (
        COUNT ( 'Table'[Emp ID] ),
        FILTER (
            ALL ( 'Table' ),
            [Emp ID] = SELECTEDVALUE ( 'Table'[Emp ID] )
                && [Data Dump Date] >= SELECTEDVALUE ( 'Table'[Data Dump Date] )
        )
    )
    Joined = 
    CALCULATE (
        COUNT ( 'Table'[Emp ID] ),
        FILTER (
            ALL ( 'Table' ),
            [Data Dump Date] = MAX ( 'Table'[Data Dump Date] )
                && [Count1] = 1
        )
    )
    Released = 
    CALCULATE (
        COUNT ( 'Table'[Emp ID] ),
        FILTER (
            ALL ( 'Table' ),
            [Data Dump Date] = MIN ( 'Table'[Data Dump Date] )
                && [Count2] = 1
        )
    )

    Is this the result you expect?

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Powerful's avatar
      Powerful
      Frequent Visitor

      Hi v-zhangti,

      Thanks this is working fine.

       

      I have more than 2 dates in my data.

      I have put date slicer also. I'm trying to do this for only 2 dates as you have done, those 2 dates should come from slicer MIN and MAX. I trying to modify the measures to get the results for more than 2 dates but unable to do it. Please help me..

      Appreciate your support!!