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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Spawebin
Frequent Visitor

Porcentaje de variación respecto al dato anterior (periodos discontinuos en horas)

Que tal amigos, estoy tratando de hacer una medida en DAX donde quiero obtener la variación y el porcentaje de incremento de una fila con respecto al dato anterior (generalmente es en horas), mi tabla de fechas contine las horas del registro.

 

Ejemplo:

IDDATEHOURDATE_ALLRESULTANTEVARIATIONPERCENTAGE
SE-10103/05/202202:25:08 a. m.03/05/2022 02:25218  
SE-10103/05/202203:14:16 a. m.03/05/2022 03:14217-1.00-0.46%
SE-10103/05/202204:15:48 a. m.03/05/2022 04:152203.001.38%
SE-10103/05/202205:15:30 a. m.03/05/2022 05:15215-5.00-2.27%
SE-10103/05/202206:14:39 a. m.03/05/2022 06:142194.001.86%
LF-12103/05/202202:27:59 a. m.03/05/2022 02:27150  
LF-12104/05/202203:17:10 a. m.04/05/2022 03:171555.003.33%
LF-12105/05/202204:19:34 a. m.05/05/2022 04:191561.000.65%
LF-12105/05/202205:18:27 a. m.05/05/2022 05:181582.001.28%
LF-12106/05/202206:19:17 a. m.06/05/2022 06:191602.001.27%

 

Spawebin_6-1651856192284.png

 

 

Realizado en Excel, a estos resultados quiero llegar, corresponde a las dos últimas columnas (VARIATION y PORCENTAGE).

Variation: dato actual (o último) menos el anterior.

Spawebin_7-1651856207043.png

 

 

Porcentage: dato actual (o último) entre el anterior, el resultado menos 1.

Spawebin_8-1651856217845.png

 

 

Agradezco cualquier aporte!

 

Saludos desde México!

 

 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Spawebin 

Thanks for reaching out to us.

you can try this, create 2 measures,

VARIATION mea = 
var _pre=CALCULATE(MAX('Table'[DATE_ALL]),FILTER(ALL('Table'),'Table'[ID]=MIN('Table'[ID]) && 'Table'[DATE_ALL]<MIN('Table'[DATE_ALL])))
var _preRES=CALCULATE(MAX('Table'[RESULTANTE]),FILTER(ALL('Table'),'Table'[ID]=MIN('Table'[ID]) && 'Table'[DATE_ALL]=_pre))
return IF(ISBLANK( _preRES),BLANK(), MIN('Table'[RESULTANTE])-_preRES)
PRECENTAGE mea = 
var _pre=CALCULATE(MAX('Table'[DATE_ALL]),FILTER(ALL('Table'),'Table'[ID]=MIN('Table'[ID]) && 'Table'[DATE_ALL]<MIN('Table'[DATE_ALL])))
var _preRES=CALCULATE(MAX('Table'[RESULTANTE]),FILTER(ALL('Table'),'Table'[ID]=MIN('Table'[ID]) && 'Table'[DATE_ALL]=_pre))
return IF(ISBLANK( _preRES),BLANK(),DIVIDE( MIN('Table'[RESULTANTE]),_preRES)-1)

result

vxiaotang_0-1652079816676.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Harmenszoonblac
New Member

Buenos Dias Comunidad, Tengo un problema similar sin embargo mi complejidad es que necesito sacar la variacion con respecto a una medida, la estructura de mi tabla es asi:

Harmenszoonblac_0-1693317232426.png


son multiples ubicaciones y ciudades y necesito sacar una variacion de cada columna o en su defecto de la medida resultante de ellas. He intentado todos los medios incluidos los IA y no doy con la respuesta adecuada. Solicito de ayuda

Spawebin
Frequent Visitor

Awsom!!!

😁

Great contribution, thanks!!!

 

v-xiaotang
Community Support
Community Support

Hi @Spawebin 

Thanks for reaching out to us.

you can try this, create 2 measures,

VARIATION mea = 
var _pre=CALCULATE(MAX('Table'[DATE_ALL]),FILTER(ALL('Table'),'Table'[ID]=MIN('Table'[ID]) && 'Table'[DATE_ALL]<MIN('Table'[DATE_ALL])))
var _preRES=CALCULATE(MAX('Table'[RESULTANTE]),FILTER(ALL('Table'),'Table'[ID]=MIN('Table'[ID]) && 'Table'[DATE_ALL]=_pre))
return IF(ISBLANK( _preRES),BLANK(), MIN('Table'[RESULTANTE])-_preRES)
PRECENTAGE mea = 
var _pre=CALCULATE(MAX('Table'[DATE_ALL]),FILTER(ALL('Table'),'Table'[ID]=MIN('Table'[ID]) && 'Table'[DATE_ALL]<MIN('Table'[DATE_ALL])))
var _preRES=CALCULATE(MAX('Table'[RESULTANTE]),FILTER(ALL('Table'),'Table'[ID]=MIN('Table'[ID]) && 'Table'[DATE_ALL]=_pre))
return IF(ISBLANK( _preRES),BLANK(),DIVIDE( MIN('Table'[RESULTANTE]),_preRES)-1)

result

vxiaotang_0-1652079816676.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.