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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
ngulminelli
Frequent Visitor

Problem with comparing row values in the same column

Hi guys I have some this issue when trying to compare the current price with the ones in the past.

 

What I would like is to have the percentage change between the last precio_unitario paid and the other precio_unitario that the same description was paid in the pass. Then I have in the report a slicer to select the Descrption and with a matrix, have the Description, date, precio_unitario for each purchase and besides the % paid with the inmmediate below.

 

Hope is clear enough!

 

I have the following table:

fechaProveedorDescripcionQuantityPriceprecio_unitario
08-04-19 00:00PROVEEDOR 2Access Insulina x 10028710.6$4,355.30
01-04-19 00:00PROVEEDOR 2Access Insulina x 10028594.2$4,297.10
22-03-19 00:00PROVEEDOR 2Access Insulina x 10014074$4,074.00
11-03-19 00:00PROVEEDOR 2Access Insulina x 10028186.8$4,093.40
14-02-19 00:00PROVEEDOR 2Access Insulina x 10027585.4$3,792.70
05-02-19 00:00PROVEEDOR 2Access Insulina x 10027391.4$3,695.70
23-01-19 00:00PROVEEDOR 2Access Insulina x 100311174.4$3,724.80
14-01-19 00:00PROVEEDOR 2Access Insulina x 10013666.6$3,666.60
07-01-19 00:00PROVEEDOR 2Access Insulina x 10013715.1$3,715.10
1 ACCEPTED SOLUTION
TeigeGao
Solution Sage
Solution Sage

Hi @ngulminelli ,

According to your description, my understanding is that you want to calculate the  % paid between he last precio_unitario paid and the other precio_unitario that the same description was paid in the pass. In another word, it is precio_unitario of the latest fecha / precio_unitario of other rows in the same Descripcion.

We can use the following DAX query:

Measure = var thelastone = CALCULATE(MIN(Table1[precio_unitario]),FILTER(ALL(Table1),Table1[fecha] = MAX(Table1[fecha])))
return DIVIDE(thelastone,SUM(Table1[precio_unitario]) - thelastone)

Best Regards,

Teige

View solution in original post

3 REPLIES 3
TeigeGao
Solution Sage
Solution Sage

Hi @ngulminelli ,

According to your description, my understanding is that you want to calculate the  % paid between he last precio_unitario paid and the other precio_unitario that the same description was paid in the pass. In another word, it is precio_unitario of the latest fecha / precio_unitario of other rows in the same Descripcion.

We can use the following DAX query:

Measure = var thelastone = CALCULATE(MIN(Table1[precio_unitario]),FILTER(ALL(Table1),Table1[fecha] = MAX(Table1[fecha])))
return DIVIDE(thelastone,SUM(Table1[precio_unitario]) - thelastone)

Best Regards,

Teige

Hi Teige that´s exactly wright,  it worked fine! thank you very much!

Hi @TeigeGao that solved part of my problem, but what I was really trying to solved is to calculate the % difference between price on index 1 from index 2, then from index 2 % difference from index 3, and so on....

 

is it posible? I managed to get the last price, but can figure out how to iterate....

 

DatePriceIndex
01-04-19 00:00$2,493.201
22-03-19 00:00$2,363.762
14-02-19 00:00$2,200.553
30-01-19 00:00$2,172.414
14-01-19 00:00$2,127.385
07-01-19 00:00$2,155.526
23-11-18 00:00$2,104.877
07-11-18 00:00$2,048.598
19-10-18 00:00$2,110.509
08-10-18 00:00$2,178.0410
17-09-18 00:00$2,273.7111
22-08-18 00:00$1,029.9212

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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