Forum Discussion

Jsua's avatar
Jsua
Regular Visitor
9 years ago

create a new column using values from another column.

Hello guys. I´m new in this forum though I´ve got some answers since months. 

My problem is that I want to create a new column in a new table I´ve calculated. This new column should take the value of the column Total_Ventas but for the year previous only when the column Index is different form 1. Getting this I could calculate a new column that measure the variation between the actual year and the previous one. In the image attach is a sample of my dataset and the column "Wish" is the one that I want to create. I have tryed with the following DAX expression but what I get is wrong.

 Venta_Previa = CALCULATE(MAX('Totales_Año_Cliente_Articulos'[Total_Ventas]),FILTER('Totales_Año_Cliente_Articulos','Totales_Año_Cliente_Articulos'[Index]<EARLIER('Totales_Año_Cliente_Articulos'[Index])))MY_Dataset

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Jsua,

    Firstly, add another Index column from 1 to 20 in your table.

    Secondly, based on your above screenshot, I am not sure if the TIENDA column contains numbers like 2012, 2013 and so on, if not, create wish column using the following formula.

    Wish = IF('Totales_Año_Cliente_Articulos'[TIENDA]=LOOKUPVALUE('Totales_Año_Cliente_Articulos'[TIENDA],'Totales_Año_Cliente_Articulos'[Index.1],'Totales_Año_Cliente_Articulos'[Index.1]-1),LOOKUPVALUE('Totales_Año_Cliente_Articulos'[Total_Ventas],'Totales_Año_Cliente_Articulos'[Index.1],'Totales_Año_Cliente_Articulos'[Index.1]-1),0)



    However, if the value of TIENDA column is like “2012Avboyaca”, then create a column using the following formula.

    Column = RIGHT('Totales_Año_Cliente_Articulos'[TIENDA],LEN('Totales_Año_Cliente_Articulos'[TIENDA])-4)

    Then create wish column using the formula below.

    Wish = IF('Totales_Año_Cliente_Articulos'[Column]=LOOKUPVALUE('Totales_Año_Cliente_Articulos'[Column],'Totales_Año_Cliente_Articulos'[Index.1],'Totales_Año_Cliente_Articulos'[Index.1]-1),LOOKUPVALUE('Totales_Año_Cliente_Articulos'[Total_Ventas],'Totales_Año_Cliente_Articulos'[Index.1],'Totales_Año_Cliente_Articulos'[Index.1]-1),0)