Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
axeelcs
Regular Visitor

Last year value but without format date

Hi everyone, I am having this issue where I have to calculate the last year value, but I am not working with a format Date, because we are working with weeks.

 

I have a table like this, called View_BT_Comercial

 

 

 

In my page, I 've this filters wich I want to keep for the calculate of the last year:

 

 

So in one of my measures the DAX functions that i use to calculate the actual year and the last are :

ACTUAL : 

 

Ventas_Totales = SUMX(View_BT_Comercial,View_BT_Comercial[Precio_Unitario]*View_BT_Comercial[Unidades])

LAST YEAR :

 

ventas_totales_LY = CALCULATE(sumx(View_BT_Comercial,View_BT_Comercial[Precio_Unitario]*View_BT_Comercial[Unidades]),filter(all(View_BT_Comercial),View_BT_Comercial[anioretail] =max(View_BT_Comercial[anioretail_ant]) && View_BT_Comercial[MesRetail] =max(View_BT_Comercial[MesRetail]) && View_BT_Comercial[semanaRetail] <=max(View_BT_Comercial[semanaRetail]) && View_BT_Comercial[Sucursal_ID]<=max(View_BT_Comercial[Sucursal_ID] )))

So, I tried with just the calculated filters, but the equal "=" doesn't wok, then I tried with the function FILTER(ALL( ... like i posted, but when I dont select a month, or week, or sucursal,  it gives a wrong result, because of the "max" function ... so the next that i tried was FILTER(ALLEXCEPT( and put the columns sucursal, month and week, but nothing too .. I tried also with VALUES().

 

I really dont know what to use ... Like i said before, cause I am not working with a date format, i created a calculated column wich "anioretail-1" so i can get the last year, mainly because I cant use DATEADD.

 

I need to get the last year value for the same month, week and sucursal, are o aren't filtered values.

 

Thanks !!!

3 REPLIES 3
Vvelarde
Community Champion
Community Champion

@axeelcs

 

Hi, try with this:

 

 

TotalVentasPY =
CALCULATE (
    [TotalVentas],
    FILTER (
        ALL ( Table1 ),
        Table1[Año]
            = SELECTEDVALUE ( Table1[Año] ) - 1
            && Table1[Mes] = SELECTEDVALUE ( Table1[Mes] )
            && Table1[Semana] = SELECTEDVALUE ( Table1[Semana] )
            && Table1[Sucursal] = SELECTEDVALUE ( Table1[Sucursal] )
    )
)

Regards

 

Victor

Lima  - Peru

 




Lima - Peru

Hi Victor, thanks for the reply, but it only works when I have all the filter selected, but when I dont have nothing filtered it doesnt show anything.

Vvelarde
Community Champion
Community Champion

@axeelcs

 

Try with:

 

TotalVentasPY =
CALCULATE (
    [TotalVentas],
    FILTER (
        ALLEXCEPT ( Table1; Table1[Mes], Table1[Semana]; Table1[Sucursal] ),
        Table1[Año]
            = SELECTEDVALUE ( Table1[Año] ) - 1
    )
)



Lima - Peru

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.