Forum Discussion
YTD
- 4 years ago
En ella @atasgao ,
Cree una columna en la tabla DimDate para obtener el 8º business_day de cada mes.
YearMonth = FORMAT(dimdate[Date],"YYYYMM") business_day = IF(WEEKDAY('dimdate'[Date],2)<=5,'dimdate'[Date]) is_eight = RANKX(FILTER(dimdate,dimdate[business_day]<>BLANK()&&dimdate[YearMonth]=EARLIER(dimdate[YearMonth])),dimdate[business_day],,ASC) 8_business_day = CALCULATE(MAX(dimdate[Date]),FILTER(dimdate,dimdate[YearMonth]=EARLIER(dimdate[YearMonth])&&[is_eight]=8))Luego cree medidas para obtener el valor del mes pasado o antes del mes pasado.
last_1_month = CALCULATE(SUM('Table'[Budget]),FILTER(ALL('Table'),FORMAT(EDATE('Table'[Date],+1),"YYYYMM")=SELECTEDVALUE(dimdate[YearMonth]))) last_2_month = CALCULATE(SUM('Table'[Budget]),FILTER(ALL('Table'),FORMAT(EDATE('Table'[Date],+2),"YYYYMM")=SELECTEDVALUE(dimdate[YearMonth]))) eight_bussiness = IF(SELECTEDVALUE(dimdate[8_business_day])<=TODAY(),'Table'[last_1_month],'Table'[last_2_month]) last_1_month_YTD = CALCULATE(SUM('Table'[Budget]),FILTER(ALL('Table'),FORMAT(EDATE('Table'[Date],+1),"YYYYMM")<=SELECTEDVALUE(dimdate[YearMonth]))) last_2_month_YTD = CALCULATE(SUM('Table'[Budget]),FILTER(ALL('Table'),FORMAT(EDATE('Table'[Date],+2),"YYYYMM")<=SELECTEDVALUE(dimdate[YearMonth]))) eight_bussiness_YTD = IF(SELECTEDVALUE(dimdate[8_business_day])<=TODAY(),'Table'[last_1_month_YTD],'Table'[last_2_month_YTD])También puede agregar [project_name] para filtrar la codición.
Pbix como adjunto.
Saludos
Arrendajo
¿Es la versión keepfilters lo que estás buscando entonces?
M_YTDBudget =
VAR EightBusinessday =
CALCULATE (
MIN ( DimDate[Date] ),
DimDate[CurrentMonthBusinessDay] = 8
)
VAR EndDate =
IF (
TODAY () < EightBusinessday,
EOMONTH ( TODAY (), -2 ),
EOMONTH ( TODAY (), -1 )
)
RETURN
CALCULATE (
[M_AnnualBudgetByMonth],
KEEPFILTERS ( DimDate[Date] <= EndDate )
)Adjuntando una captura de pantalla: donde se muestra la fecha de finalización 30/11/2021. y si selecciono el EightBusinessday como 15, entonces la fecha es 1/24/2022 Por lo tanto, los datos deben completarse hasta el 30/11/2021 y no hasta el mes de diciembre. Y después del 24/01/2022 los datos se mostrarán hasta diciembre
Ahora, todavía los datos se están rellenando durante todos los meses si uso la versión keepfilters. Quiero filtrar los datos de YTD hasta el mes de noviembre.
¿Alguna idea de cómo puedo lograr eso?
Antes usaba la siguiente fórmula, pero como el año cambió ahora, la fórmula no funciona
= CALCULATE([M_AnnualBudgetByMonth],FILTER(ALL( DimDate[Month] ), DimDate[Month] <= IF(Day(Now())<=15,Month(Now())-2,MONTH(Now())-1)))
Gracias