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