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
Abhi_PBI
Frequent Visitor

How to handle slowly changing dimension

Hi All,

Hope you are doing well.

I have a report which is dependent on HR data. on my report i have Emp ID (not unique), Emp Grade, Application ID (unique) application date, Status and so on.. The "Grade" field comes from HR data which is a system extract contains employee details including employee ID and Grade. This problem is the employee grade changes over time and the HR data gets updated with new grade replacing old value. But I don't want the emp grade changed for the old records. However if the employee has applied again there will be a new entry on the table with new application ID and i want the new grade to be reflected. While creating the application data base I've created a fixed emp grade table to populate the grade for all existing record. now the idea is if a new record is added the fixed grade Col. will be blank and the New grade col will be filled with updated Grade for all employees. there is one more Col as effective grade which is nothing but  ...

Effective Grade= If(NOT(ISBLANK('Application table'[Fixed grade])),'Application table'[Fixed grade],'Application table'[New Grade])
 
This is working at the moment. But surely not a correct model. Because if after a year or so the same employee applies again and his grade gets changed then his previous record will be changed because fixed grade col is blank. For example Lets say EMP6 applies again in Oct 2020 and become VP by then. So, along with the new entry the grade against APP011 will also be changed to VP from AVP. This is what i'm trying to avoid. So i need a better and sustainable model. Could anyone please help me with some idea?
 ApplicationTable
Application_IDEMP_IDApplication DateStatusFixed Grade (old record till Aug 2019)New GradeEffective Grade
APP001EMP11-Jan-18RejectedAMMAM
APP002EMP25-Apr-18ApprovedMSMM
APP003EMP310-Apr-18ApprovedMSMM
APP004EMP411-Nov-18ApprovedAMMAM
APP005EMP34-Mar-19ApprovedMSMM
APP006EMP46-Jun-19ApprovedMMM
APP007EMP529-Jun-19ApprovedAVPVPAVP
APP008EMP77-Jul-19RejectedAMAMAM
APP009EMP58-Aug-19ApprovedVPVPVP
APP010EMP822-Aug-19ApprovedAVPVPAVP
APP011EMP61-Oct-19Approved AVPAVP
APP012EMP15-Oct-19Rejected MM
APP013EMP93-Nov-19Pending SVPSVP
APP014EMP215-Nov-19Pending SMSM
APP015EMP101-Dec-19Pending EVPEVP

 

EMP IDGrade
EMP1M
EMP2SM
EMP3SM
EMP4M
EMP5VP
EMP6AVP
EMP7AM
EMP8VP
EMP9SVP
EMP10EVP

 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Abhi_PBI 

Create a table

Table 2 = VALUES('Table'[EMP_ID])

Capture13.JPG

Then create measures

Measure =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Application_ID] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[EMP_ID] = MAX ( 'Table'[EMP_ID] )
            && 'Table'[Application Date] <= MAX ( 'Table'[Application Date] )
    )
)

Measure 2 =
CALCULATE (
    MAX ( 'Table'[Application Date] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[EMP_ID] = MAX ( 'Table'[EMP_ID] )
            && [Measure] > 1
    )
)


Measure 3 =
CALCULATE (
    MAX ( 'Table'[New Grade] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[EMP_ID] = MAX ( 'Table'[EMP_ID] )
            && [Application Date] = [Measure 2]
    )
)


Measure 4 = IF([Measure 3]=BLANK(),MAX('Table'[New Grade]),[Measure 3])

Capture12.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Abhi_PBI
Frequent Visitor

Thanks Maggie.

I'll try implementing this in my actual data and see the result. Thanks for your valuable time.

 

Regards,

Abhi

v-juanli-msft
Community Support
Community Support

Hi @Abhi_PBI 

Create a table

Table 2 = VALUES('Table'[EMP_ID])

Capture13.JPG

Then create measures

Measure =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Application_ID] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[EMP_ID] = MAX ( 'Table'[EMP_ID] )
            && 'Table'[Application Date] <= MAX ( 'Table'[Application Date] )
    )
)

Measure 2 =
CALCULATE (
    MAX ( 'Table'[Application Date] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[EMP_ID] = MAX ( 'Table'[EMP_ID] )
            && [Measure] > 1
    )
)


Measure 3 =
CALCULATE (
    MAX ( 'Table'[New Grade] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[EMP_ID] = MAX ( 'Table'[EMP_ID] )
            && [Application Date] = [Measure 2]
    )
)


Measure 4 = IF([Measure 3]=BLANK(),MAX('Table'[New Grade]),[Measure 3])

Capture12.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-juanli-msft
Community Support
Community Support

Hi @Abhi_PBI 

Based on my understanding, the system changes employee's grade over time,

but you don't want the new grade to repalce the old one, except when the employee has a new application id.

Right?

 

However, i have a doubt that since the system changes employee's grade over time, new grade will replace old one,

old one would not remain in system, how can we keep the old one in Power BI?

"the employee grade changes over time and the HR data gets updated with new grade replacing old value"

 

For the question above, i think we can make a copy of the old records and keep it as a local file.

Do you accept my suggestion or do you take other ways?

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.