Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Icon for Administrator rankAdministrator
4 years ago
Solved

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...
  • Syndicate_Admin's avatar
    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