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
¿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_Admin4 years ago
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_Admin4 years ago
Administrator
@AlexisOlson El CurrentMonthBusinessDay da el día hábil cada mes. Entonces, básicamente quiero mostrar los datos hasta diciembre, ya que el 8º día hábil para este mes es el 12 de enero, pero antes del 8º día hábil, es decir, antes del 12 de enero, debería mostrar los datos hasta noviembre.
Ahora los cálculos anteriores me dan un valor agregado para todos los meses.
Gracias
Aakanksha
- Syndicate_Admin4 years ago
Administrator
¿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 ) )