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.
Tengo una situación en la que quiero contar el número de días disponibles en el año en curso.
Hay una columna de fecha de inicio de decir 01/01/2000
Fecha de finalización columna de decir 31/12/2099
Esto tendría que devolver la disponibilidad de 366 días
No obstante, se puede introducir una fecha de inicio como 01/04/2020
Fecha de finalización 31/12/2099
Esto tendría que volver 275 días.
Ayuda apreciada
@johnce123 ¿Tiene una tabla DimDate? ¿En qué formato se encuentran los datos (es decir, cómo se introducen las fechas de inicio y finalización y en qué tabla y se relaciona con la tabla DimDate?)? Usted podría utilizar:
Días en el año ?
VAR _StartDate - IF(YEAR(Table[StartDate]) <YEAR(TODAY()), DATE(YEAR(TODAY()), 1, 1), Table[StartDate])
VAR _EndDate - IF(YEAR(Table[EndDate]) > YEAR(TODAY()), DATE(YEAR(TODAY()), 12, 31), Table[EndDate])
devolución
CALCULATE(COUNTROWS(ALL(DimDate)), DATESBETWEEN(_StartDate, _EndDate))
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Hola, es una consulta directa en una base de datos SQL que es mi sistema de gestión en vivo (centro de negocios) y devuelve una fecha junto con una hora.
Gracias por tu ayuda
Puede utilizar esta medida:
_QtDays =
SUMX('Table',
IF(
YEAR('Table'[StartDate]) <> YEAR(TODAY()),
DATEDIFF(DATE(YEAR(TODAY()), 1,1), DATE(YEAR(TODAY()), 12,31), DAY) + 1,
DATEDIFF('Table'[StartDate], DATE(YEAR('Table'[StartDate]), 12,31), DAY) + 1
))
¿Se tendría también en cuenta esto si la fecha de finalización cayera antes de que finalice el año en curso
así que si mi fecha de finalización fuera 31/08/2020 calcularía desde la fecha de inicio o el comienzo del año hasta el 31/08/2020?
Pruebe esta medida:
_QtDays =
SUMX(
'Table',
VAR _tbDates = FILTER(CALENDAR('Table'[StartDate], 'Table'[EndDate]), YEAR([Date]) = YEAR(TODAY()))
RETURN COUNTROWS(_tbDates))
@johnce123 - Puede utilizar DATEDIFF como:
Measure Remaining Days =
VAR beginDate = DATE(2020,4,1)
RETURN
DATEDIFF(beginDate,MAX('Table'[Date]),DAY )
Proud to be a Super User!
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 |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |