Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
smb711
Helper I
Helper I

How to determine which is the current record between multiple records for an employee

I need to show which record is the 'active' record when using a dynamic date slicer

 

No two records for an employee overlap position starts 

 

Say I had a date with a date range of April 2012 to May 2013 the current active record would be

592342Joe Bloggs1/04/20121/05/2013

Contract

 

Say I had a date slicer with a date range of September 2019 - October 2020 the current active record would be 

592342Joe Bloggs16/09/201919/10/2020Part-time

 

Employee numberNamePosition start datePosition end dateEmployment Basis
592342Joe Bloggs1/04/20121/05/2013Contract
592342Joe Bloggs2/05/20133/05/2015Part-time
592342Joe Bloggs4/05/201515/09/2019Full-time
592342Joe Bloggs16/09/201919/10/2020Part-time
592342Joe Bloggs20/10/2020 Full-time
347977Sam Bills19/10/201925/12/2020Part-time
347977Sam Bills26/12/202015/01/2021Casual
347977Sam Bills16/01/202131/12/2021Full-time

 

12 REPLIES 12
parry2k
Super User
Super User

@smb711 you have to add this a MEASURE not a COLUMN



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thank you for your help with troubleshooting, I don't think it is returning the right result: there should be a sum of hundreds of active FTE 

 

Data facts to support:

  • Every employee only ever gets one employee number
  • Each employee can have several position records 
  • When the slicer is linked to a date table, which is filtered to cap the distinct count of position records per employee number to show the most recent entry within the date filters 
  • SUM the most current entry per an employee per the selected date parameters to determine the actual FTE in past or future months of a year

example.PNG

Filter Employee = 
VAR __startDate = MIN ( DateTable[Date] )
VAR __endDate = MAX ( DateTable[Date] )
RETURN
CALCULATE (
    COUNTROWS ( PBIPND_vwPosition_Private ),

    KEEPFILTERS ( 
        PBIPND_vwPosition_Private[StartDate] >= __startDate
    ),
    KEEPFILTERS (
        PBIPND_vwPosition_Private[EndDate] <= __endDate
   ),
   KEEPFILTERS (
        NOT ISBLANK ( PBIPND_vwPosition_Private[EndDate] ) 
    )

)

 

parry2k
Super User
Super User

@smb711 try this:

 

Filter Employee = 
VAR __startDate = MIN ( 'Date'[Date] )
VAR __endDate = MAX ( 'Date'[Date] )
RETURN
CALCULATE (
    COUNTROWS ( Emp ),

    KEEPFILTERS ( 
        Emp[Position start date] >= __startDate
    ),
    KEEPFILTERS (
        Emp[Position end date] <= __endDate
   ),
   KEEPFILTERS (
        NOT ISBLANK ( Emp[Position end date] ) 
    )

)

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks this seems to be operating, however, runs into an error:

 

!A circulate dependency was detected: PBIPND_vwPosition_Private[Column], PBIND_vwPosition_Private[Current FTE], PBIPND_vwPosition_Private[Column].

 

A circular dependencycy was detected:

  • PBIPND_vwPosition_Private[Column],
  • PBIPND_vwPosition_Private[Current FTE],
  • PBIPND_vwPosition_Private[Column].

 

A column from the Position vw is getting picked up? Actual FTE is a decimal type column

parry2k
Super User
Super User

@smb711 January 2021 is an old version, you need to get at least Aug/Sep 2021 release and today there is Oct 2021 release.

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks for letting me know, I don't have access to this version from my workplace. Any suggestions on workarounds? 

parry2k
Super User
Super User

@smb711 Anyhow first and foremost is to solve the issue of why my measure is not working in your case?

 What Power BI version you are using? Can you please confirm?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

I have the newest update - version: 2.88.2361.9 64-bit (January 2021)

 

I think it is the syntax for the variable which is incorrect for my situation and I am not replacing them correctly, could you please replace them using the following field and table names I am using? Apologies

 

I am not sure what to put in emp as well

 

Table: PBIPND_vwPositionPrivate

Start date column name: StartDate

End date column name:  EndDate

Employee number column name: StaffNumber

 

Date table name: Date Table

Date column name: Date

 

Is it because I am referencing two tables

!! The expression contains multiple columns, but only a single column can be used in a true/false expression that is used as a table filter expression

 

Filter Employee =

VAR __startDate = MIN ( 'Date Table'[Date] )

VAR __endDate = MAX ( 'Date Table'[Date] )

RETURN

CALCULATE (

    COUNTROWS (PBIPND_vwPosition_Private ),

 

    KEEPFILTERS (

        PBIPND_vwPosition_Private[StartDate] >= __startDate &&

        PBIPND_vwPosition_Private[EndDate] <= __endDate &&

        NOT ISBLANK ( PBIPND_vwPosition_Private[EndDate] )

    )

 

)

 

 

parry2k
Super User
Super User

@smb711 assuming you have a date dimension in your model that you will use for the slicer, if not then you can add one using my blog post here Create a basic Date table in your data model for Time Intelligence calculations | PeryTUS IT Solutio...

 

Create a new measure to filter employees that falls in the selected date range:

 

 

Filter Employee = 
VAR __startDate = MIN ( 'Date'[Date] )
VAR __endDate = MAX ( 'Date'[Date] )
RETURN
CALCULATE (
    COUNTROWS ( Emp ),

    KEEPFILTERS ( 
        Emp[Position start date] >= __startDate &&
        Emp[Position end date] <= __endDate && 
        NOT ISBLANK ( Emp[Position end date] ) 
    )

)

 

 

Create a table visual, add all the columns you want in the visual, add a visual level filter, and add above measure and where value = 1 and that will do it.

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks so much Parry2k for your help with this

 

I am running into a couple of issues

  • My employee table with an employee number, position start date and position end date is called Sheet1
  • My date table dimension table: [date] date table

Scenario

  • Every employee has a position record with a start date
  • Some employees may have multiple position records over time 
    • No two-position records per an employee can have an overlapping start date
  • I need to identify using a data slicer with month and years (from date table) which is the active position record for the employee at a moment in time so I can only ever see a maximum of one position record per an employee 
  • I am not sure how to do this - I am trying to identify one active position record amongst multiple inactive and (1) active postion per an employee 

 

smb711_0-1634039330714.png

 

I guess I am trying to identify the max record at a moment in time whether in the past or present. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.