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
amirabedhiafi
Impactful Individual
Impactful Individual

Calculate Salary by month using calculated column

I have the following calculated column : 

TotalWagePerDay =
IF (
'Time'[DayType]= "Holiday", RELATED(Employees[Hourly Wage]) * [Hours] * 2,
(RELATED(Employees[Hourly Wage]) * [Hours] ) + 1.5 * ([Hours]-8
)
)
I want to calculate the [Salary by month] (as a calculated column using DAX for each employee) to have a matrix like below :
matrix.PNG
  • Table [Time] contains [Date], [Hours], [DayType] and [TotalWagePerDay] columns
  • Table [Dates] contains [DayType]
  • Table [Employees] contains [Employee] and [Hourly Wage]
 

 

Amira Bedhiafi
Full Stack Business Intelligence Consultant @Capgemini
1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @amirabedhiafi 

Due to you use "related" function in calculated column, your Table[Time] and Table[Employee] should be related.

I think your Table[Time] contains [employee].

I build a sample to achieve your goal.

Time:

2.png

Dates:

MonthName and Month columns are calculated columns.

MonthName = FORMAT(Dates[Date],"MMMM")
Month = MONTH(Dates[Date])

3.png

Employees:

4.png

Relationship:

5.png

Result is as below.

6.png

 

Best Regards,

Rico Zhou

 

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

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @amirabedhiafi 

Due to you use "related" function in calculated column, your Table[Time] and Table[Employee] should be related.

I think your Table[Time] contains [employee].

I build a sample to achieve your goal.

Time:

2.png

Dates:

MonthName and Month columns are calculated columns.

MonthName = FORMAT(Dates[Date],"MMMM")
Month = MONTH(Dates[Date])

3.png

Employees:

4.png

Relationship:

5.png

Result is as below.

6.png

 

Best Regards,

Rico Zhou

 

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

 

mhossain
Solution Sage
Solution Sage

Hello @amirabedhiafi 

 

Not able to understand completely though.

When you drag Date (Month) in columns, employee name in rows and SUM(Totalwageperday) in value then what issue you are facing?

 

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.