Forum Discussion
YTD
¡Hola!
Por lo tanto, el 8º día hábil de un mes en adelante, me gustaría mostrar los datos hasta el mes pasado y antes del 8º día hábil me gustaría mostrar los datos del mes anterior al último mes.
La fórmula que estoy usando aquí
CurrentDate = HOY()
MonthBack_1 = Fecha( AÑO(DimDate[CurrentDate]-25),MES(DimDate[CurrentDate]-25),01)
MonthBack_2 = Fecha( AÑO(DimDate[CurrentDate]-60),MES(DimDate[CurrentDate]-60),01)
EightBusinessday = CALCULATE(MIN(DimDate[Day]),Filter(DimDate, DimDate[CurrentMonthBusinessDay]=8 ))
M_YTDBudget = CALCULATE([M_AnnualBudgetByMonth],FILTER(ALL( DimDate[Month] ), DimDate[Month] <= IF(Day(Now())<EightBusinessday, MAX(Dimdate[monthBack_2]), MAX(Dimdate[monthBack_1])))))
Este M_YTD me está dando datos de todos los meses.
Gracias
Aakanksha
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
7 Replies
- Syndicate_Admin
Administrator
¿Qué tal esto en su lugar?
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], DimDate[Date] <= EndDate )- Syndicate_Admin
Administrator
- Syndicate_Admin
Administrator
Derecha. La lógica se basa en TODAY(), no en MonthName.
Si desea algo diferente, explique cómo se define CurrentMonthBusinessDay (¿es solo el mes actual o da el día hábil en cada mes?) y cómo espera que funcione el cálculo en su escenario de captura de pantalla.
- Syndicate_Admin
Administrator
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