Forum Discussion

ngulminelli's avatar
ngulminelli
Frequent Visitor
7 years ago
Solved

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...
  • TeigeGao's avatar
    7 years ago

    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