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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Daniels2204
Frequent Visitor

Como calcular la diferencia entre valores numéricos ubicadas en la misma columna

Hola Todos,

 

Tengo el siguiente problema, necesito buscar la diferencia entre dos numeros (kilometros) ubicados en la misma columna y sumar su diferencia a final de mes.

 

Daniels2204_0-1596156794261.png

El problema principal es que la tabla tiene distintos TP_CODBEM y se informan en distintas fechas, por lo que aveces los kilometrajes no estan en orden, como se evidencia en la tabla

Daniels2204_1-1596156975290.png

 

Agradeceria me ayudaran con una funcion que me ayude a solucionar.

 

7 REPLIES 7
amitchandak
Super User
Super User

@Daniels2204 , Try like

value = [TP_POS_CONT] - maxx(filter(table, table[TP_CODBEM] = earlier([TP_CODBEM]) && table[TP_DTORIGI] = earlier([TP_DTORIGI]) && table[TP_POS_CONT] < earlier([TP_POS_CONT])),[TP_POS_CONT])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Daniels2204_0-1596202258003.png

Hi, @amitchandak 

Forget to comment that the table is in Directquery mod and I found that MAXX is not compatible.

 

Thank You, @amitchandak 

 

But when writing the formula as is, it generates the error with "="

Daniels2204_2-1596199875346.png

 

Then, corrected the error showed up to "FILTER"

 

Daniels2204_0-1596199800406.png

I wait for comments,

 

Cheers,

@Daniels2204 , value= was also not required. 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi, @amitchandak 

 

Continuos the error,

 

Daniels2204_0-1596203436544.png

 

lbendlin
Super User
Super User

So for each TP_CODBEM you need to find the smallest and largest odometer reading and get the difference, right?

Hi, @lbendlin 

I need for each TP_CODBEM to find the kilometers traveled for each month, subtracting the kilometers from each other and adding their result

Helpful resources

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