Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hola a todos
Tengo estos datos a continuación y una tabla de fechas. Mark fue promovido a diferentes roles, de ahí el cambio en su salario. Me gustaría calcular su salario mensual y su salario prorrateado en función de sus fechas de inicio y finalización
Empleado | Fecha de inicio | Fecha final | Anual | Mensual | Aumentar |
Marcos López | 5/17/2021 | 1,200,000.00 | 100,000.00 | ||
Marcos López | 7/1/2021 | 1,500,000.00 | 125,000.00 | 300,000 | |
Marcos López | 9/1/2021 | 9/15/2021 | 2,000,000.00 | 166,667.00 | 500,000 |
Mis cálculos:
Resultado:
Calculé el salario prorrateado como
Días trabajados = DATEDIFF(Empleado[Fecha de inicio], ENDOFMONTH('Fecha'[Fecha].[ Fecha]),DÍA) +1
Salario prorrateado =( Días trabajados*Mensual)/30
Pero no me devolvió lo que buscaba.
Estoy buscando tener:
Empleado | Fecha de inicio | Salario anual | Mensual | Pagado |
Marcos López | 5/17/2021 | $ 1,200,000.00 | ₱ 100.000,00 | ₱ 50.000,00 |
Marcos López | 6/1/2021 | $ 1,200,000.00 | ₱ 100.000,00 | ₱ 100.000,00 |
Marcos López | 7/1/2021 | $ 1,500,000.00 | ₱ 125.000,00 | ₱ 125.000,00 |
Marcos López | 8/1/2021 | $ 1,500,000.00 | ₱ 125.000,00 | ₱ 125.000,00 |
Marcos López | 9/1/2021 | $ 2,000,000.00 | ₱ 166.667,00 | ₱ 83.333,00 |
¡Agradece su ayuda en este!
Solved! Go to Solution.
Obtener el número de días empleados en un mes en particular es la parte más difícil, IMO.
Aquí está mi intento:
MonthlyPaid =
VAR MonthEnd = MAX ( 'Date'[Date] )
VAR MonthStart = MIN ( 'Date'[Date] )
VAR StartDate = CALCULATE ( MAX ( Employee[Start Date] ), Employee[Start Date] < MonthEnd )
VAR EndDate = CALCULATE ( MIN ( Employee[End Date] ), Employee[End Date] > StartDate )
VAR MonthlySalary =
CALCULATE (
SELECTEDVALUE ( Employee[Monthly] ),
Employee[Start Date] = StartDate
)
VAR DaysEmployed =
DATEDIFF (
MAX ( StartDate, MonthStart ),
MIN ( EndDate, MonthEnd ),
DAY
) + 1
VAR DaysInMonth = DAY ( MonthEnd )
RETURN
IF ( DaysEmployed > 0, MonthlySalary * DaysEmployed / DaysInMonth )
Es posible que solo necesite controlar null para EndDate. Vea si ayuda a reemplazar
MIN ( EndDate, MonthEnd )
con
IF ( ISBLANK ( EndDate ), MonthEnd, MIN ( EndDate, MonthEnd ) )
La medida busca un salario único. Para varios empleados, es probable que deba envolver la medida con SUMX para iterar a través de empleados separados.
SumMonthlyPaid =
SUMX ( VALUES ( Employee[Employee_Id] ), [MonthlyPaid] )
Obtener el número de días empleados en un mes en particular es la parte más difícil, IMO.
Aquí está mi intento:
MonthlyPaid =
VAR MonthEnd = MAX ( 'Date'[Date] )
VAR MonthStart = MIN ( 'Date'[Date] )
VAR StartDate = CALCULATE ( MAX ( Employee[Start Date] ), Employee[Start Date] < MonthEnd )
VAR EndDate = CALCULATE ( MIN ( Employee[End Date] ), Employee[End Date] > StartDate )
VAR MonthlySalary =
CALCULATE (
SELECTEDVALUE ( Employee[Monthly] ),
Employee[Start Date] = StartDate
)
VAR DaysEmployed =
DATEDIFF (
MAX ( StartDate, MonthStart ),
MIN ( EndDate, MonthEnd ),
DAY
) + 1
VAR DaysInMonth = DAY ( MonthEnd )
RETURN
IF ( DaysEmployed > 0, MonthlySalary * DaysEmployed / DaysInMonth )
Hola @AlexisOlson gracias por tomarse el tiempo para trabajar en esto. Utilicé su fórmula para recrear el mismo visual en su solución, pero el mes de mayo no se muestra de mi parte. ¿Qué me estoy perdiendo? Utilicé la tabla de fechas como eje x
¡Gracias!
No estoy seguro. ¿Tiene alguna relación de tabla que haga un filtrado no intencionado?
¿Tal vez intente depurar la medida devolviendo cada uno de los VAR hasta que encuentre que el que no funciona como se esperaba?
Hola @AlexisOlson he encontrado lo que me faltaba! La fórmula funciona perfectamente para empleados inactivos. Si usted es tan amable, ¿cómo puedo hacer que funcione para los empleados activos (empleados sin fechas de finalización del empleo)?
Es posible que solo necesite controlar null para EndDate. Vea si ayuda a reemplazar
MIN ( EndDate, MonthEnd )
con
IF ( ISBLANK ( EndDate ), MonthEnd, MIN ( EndDate, MonthEnd ) )
@AlexisOlson pregunta de seguimiento - (por favor disculpe mi pequeño conocimiento en dax)
al seleccionar 2 o más empleados para ver los salarios acumulados, ¿por qué se muestra así? Me gustaría que sumasan.
La medida busca un salario único. Para varios empleados, es probable que deba envolver la medida con SUMX para iterar a través de empleados separados.
SumMonthlyPaid =
SUMX ( VALUES ( Employee[Employee_Id] ), [MonthlyPaid] )
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
3 | |
1 | |
1 | |
1 | |
1 |