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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
axeelcs
Regular Visitor

Last year value without formate 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 !!!

1 REPLY 1
Eric_Zhang
Employee
Employee


@axeelcs wrote:

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 !!!


@axeelcs

What is the expected output when no month, week and sucural are selected? Maybe you could use TODAY and ISFILTER in a IF() to return values accordingly. For further advice, please post more details and expected output.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.