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
Jsua
Regular Visitor

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_DatasetMY_Dataset

1 REPLY 1
v-yuezhe-msft
Employee
Employee

@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)

1.PNG

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)

 

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.