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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.