Forum Discussion

amirabedhiafi's avatar
amirabedhiafi
Icon for Impactful Individual rankImpactful Individual
5 years ago
Solved

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 :
  • Table [Time] contains [Date], [Hours], [DayType] and [TotalWagePerDay] columns
  • Table [Dates] contains [DayType]
  • Table [Employees] contains [Employee] and [Hourly Wage]
 

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    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:

    Dates:

    MonthName and Month columns are calculated columns.

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

    Employees:

    Relationship:

    Result is as below.

     

    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. 

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    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:

    Dates:

    MonthName and Month columns are calculated columns.

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

    Employees:

    Relationship:

    Result is as below.

     

    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's avatar
    mhossain
    Icon for Solution Sage rankSolution 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?