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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
adraus
Frequent Visitor

Calculate within an IF

I want to embed calculation into a DAX IF statement.  This shouldn't be hard.  On each line of a report (one employee per line):

If an employee is salaried, I want to use the PayRate as the Wage. 

If the employee is hourly, I want to multiply the PayRate by the Hours to get Wage.

 

But I'm getting an error:

adraus_0-1655140638788.png

 

The command is:

Measure = IF(CompFixedEmpls[Plan]="Salary", SELECTEDVALUE(CompFixedEmpls[PayRate]), SELECTEDVALUE(CompFixedEmpls[PayRate]) * SELECTEDVALUE(PositionsV2[AnnualRegularHours]) )
 
I am having trouble finding out how to construct this command to get the needed results.  
(Similar to this):
adraus_2-1655141030219.png

 


 

 

 

1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

Hi @adraus ,

 

Please try this:-

Measure =
IF (
    MAX ( CompFixedEmpls[Plan] ) = "Salary",
    SELECTEDVALUE ( CompFixedEmpls[PayRate] ),
    SELECTEDVALUE ( CompFixedEmpls[PayRate] )
        * SELECTEDVALUE ( PositionsV2[AnnualRegularHours] )
)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

1 REPLY 1
Samarth_18
Community Champion
Community Champion

Hi @adraus ,

 

Please try this:-

Measure =
IF (
    MAX ( CompFixedEmpls[Plan] ) = "Salary",
    SELECTEDVALUE ( CompFixedEmpls[PayRate] ),
    SELECTEDVALUE ( CompFixedEmpls[PayRate] )
        * SELECTEDVALUE ( PositionsV2[AnnualRegularHours] )
)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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