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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
jasmin_w
Frequent Visitor

Calculated Column, 2 sets of calculations based on ID# from another table

I am trying to create a calculated column, but I need to do 2 different calculations based on ID number. I have a table of the Exempt ID numbers, a table with the Employee data, and a table that contains the actual data values. 

 

Table Names

Exempt Employees - table that includes ID numbers that I want to do a different calculation for.

Employee Data - table that contains employee information and connects all the data sources

Main - table that includes the data values by employee number.

 

Pretty much, I want to have 2 sets of calculations based on if their ID number is in the Exempt Employee Table.

  • If ID in Exempt Employee then 
    • 'Main'[Base Salary] * 'Main'[Multiplier]  / 4
  • If ID not in Exempt Employees then 
    • ('Main'[Base Salary] * 'Main'[Multiplier]) * 0.8 )) / 4

What is the best way to do this? I can also change the relationships between the 3 tables if there is a solution that way too.

 

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

Hi @jasmin_w 

 

For your question, here is the method I provided:

 

Here's some dummy data

 

“Exempt Employees”

vnuocmsft_0-1710380648948.png

 

“Employee”

vnuocmsft_1-1710380661168.png

 

“Main”

vnuocmsft_2-1710380674392.png

 

Relationships between tables.

vnuocmsft_3-1710380736730.png

 

Create a Calculated Column. This function queries whether the ID returned from the Exempt Employees table is a relevant value indicating that the employee is exempt.

 

Salary Calculation = 
    var _isExempt = 
        NOT(
            ISBLANK(
                RELATED('Exempt Employees'[ID])
            )
        )
RETURN 
    IF(
        _isExempt,
        ('Main'[Base Salary] * 'Main'[Multiplier] * 0.8) / 4, 
        ('Main'[Base Salary] * 'Main'[Multiplier] ) / 4
    )

 

Here is the result.

 

vnuocmsft_4-1710381062479.png

 

Regards,

Nono Chen

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
Ashish_Mathur
Super User
Super User

Hi,

In which of those 3 tables do you want to write those formulas?  Share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-nuoc-msft
Community Support
Community Support

Hi @jasmin_w 

 

For your question, here is the method I provided:

 

Here's some dummy data

 

“Exempt Employees”

vnuocmsft_0-1710380648948.png

 

“Employee”

vnuocmsft_1-1710380661168.png

 

“Main”

vnuocmsft_2-1710380674392.png

 

Relationships between tables.

vnuocmsft_3-1710380736730.png

 

Create a Calculated Column. This function queries whether the ID returned from the Exempt Employees table is a relevant value indicating that the employee is exempt.

 

Salary Calculation = 
    var _isExempt = 
        NOT(
            ISBLANK(
                RELATED('Exempt Employees'[ID])
            )
        )
RETURN 
    IF(
        _isExempt,
        ('Main'[Base Salary] * 'Main'[Multiplier] * 0.8) / 4, 
        ('Main'[Base Salary] * 'Main'[Multiplier] ) / 4
    )

 

Here is the result.

 

vnuocmsft_4-1710381062479.png

 

Regards,

Nono Chen

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

 

 

Thank you so much. This worked perfectly!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.