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.
Hola
Estoy buscando dividir el día laborable actual del mes por el número total de días laborables de ese mes. Me gustaría utilizar la función Today() para que sea dinámica y cambie cuando cambian los días/meses.
Por ejemplo, hoy es el 20 de octubre de 2020. Es el día 14 del mes y hay 22 días laborables en total este mes. La ecuación que estoy buscando sería 14/22.
Por favor, ayuda, he mirado a través del foro y no he visto nada.
Gracias de antemano.
Solved! Go to Solution.
Hola, @a9c4vzz , es posible que desee seguir los stpes en esta artillería con el fin de probar el código M en mi propuesta.
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
No puedo acceder al enlace 😞 se puede volver a compartir?
Hola
Tiene una tabla de 2 columnas independiente que indica qué fecha es un día festivo/fin de semana.
@a9c4vzz , En la tabla de fechas, cree una columna
Día de Trabajo: if(WEEKDAY([Date],2)>-6,0,1) // Lunes de la semana
tienen estos recuerdos
MTD Día de Trabajo CALCULATE(SUM('Date'[Día de Trabajo]),DATESMTD('Date'[Date]))
este mes Día de Trabajo - CALCULATE(SUM('Date'[Día de Trabajo]),DATESMTD(ENDOFMONTH('Date'[Date])))
Relación á divide([MTD Work Day],[este mes día laborable])
Para obtener lo mejor de la función de inteligencia del tiempo. Asegúrese de que tiene un calendario de fechas y que se ha marcado como la fecha en la vista de modelo. Además, únete a ella con la columna de fecha de tus hechos. Consulte :radacad sqlbi My Video Series Aprecia tus Felicitaciones.
Proporcione sus comentarios y consejos para nuevos videos
Tutorial Series Dax Vs SQL Direct Query PBI Consejos
Apreciamos tus Felicitaciones.
Hola, @a9c4vzz , aquí hay una solución PQ que tal vez quieras probar
let
fx = (EndDate as date) =>
let
SoM = Date.From(Date.StartOfMonth(EndDate)),
list = List.Dates(SoM, Duration.Days(EndDate - SoM)+1, #duration(1,0,0,0)),
workingdays = List.Count(List.Select(list, each [d=Date.DayOfWeek(_), result=d<>0 and d<>6][result]))
in
workingdays,
today = Date.From(DateTime.LocalNow()),
eom = Date.From(Date.EndOfMonth(DateTime.LocalNow())),
result = [Today = today, Working Days Until Today = fx(today), End of Month = eom, Working Days Until End of Month = fx(eom), Division = fx(today) / fx(eom)]
in
result
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
hola @CNENFRNL ,
¿Me cansé de eso y mi mesa se está quedando en blanco? Creé una nueva tabla y luego copie y pegé el código en una nueva columna personalizada.
Hola, @a9c4vzz , es posible que desee seguir los stpes en esta artillería con el fin de probar el código M en mi propuesta.
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@CNENFRNL Eso funcionó GRAN!! ¡¡¡Muchas gracias!!! Tu publicación fue muy útil.
Hola, @a9c4vzz
De acuerdo con su requisito, puede seguir mi paso:
Date = CALENDAR(DATE(2020,1,1),DATE(2020,12,31))
Percentage of working day=
var _curdate=TODAY()
var _workdaytilltoday=
CALCULATE(
COUNTROWS('Date'),
FILTER('Date',WEEKDAY([Date],2)<6),
DATESBETWEEN(
'Date'[Date],
DATE(YEAR(_curdate),MONTH(_curdate),1),
_curdate
))
var _workdaythismonth=
CALCULATE(
COUNTROWS('Date'),
FILTER('Date',WEEKDAY([Date],2)<6),
DATESBETWEEN(
'Date'[Date],
DATE(YEAR(_curdate),MONTH(_curdate),1),
EOMONTH(_curdate,0)))
var _result=divide(_workdaytilltoday,_workdaythismonth)
return DIVIDE(_workdaytilltoday,_workdaythismonth)
Y puedes obtener lo que quieras, así:
Aquí está mi archivo pbix de prueba, se puede descargar aquí
Saludos
Equipo de apoyo a la comunidad _Robert Qin
Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
1 |