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.
Hola, ¿Puede alguien por favor ayudarme a optimizar esta medida? Ahora tarda mucho en mostrar los resultados cuando se usa en una tabla o una matriz y es muy lento.
Es una medida "Estado", que muestra el estado de un determinado KPI en (-1,0,1) al compararlo con el destino.
¡Gracias de antemano!
_KPI Status_Target =
VAR _measureLowisGood = [MeasureID Selected] IN { 1, 2, 3 } // List all the measures where if the actual value if below target is considered good (example - Lost time Injuries)
VAR _measureHighisGood = [MeasureID Selected] IN { 6, 4, 5 } // List all the measures where if the actual value if above target is considered good (example - OTP)
VAR _Measure = [MeasureID Selected] // Measure selected by filter or which is already in a table or a matrix
VAR _bottomthreshold =
CALCULATE (
VALUES ( '1-DimKPICat'[Lower Threshold] ),
FILTER ( '1-DimKPICat', '1-DimKPICat'[KPIID] = _Measure )
)
VAR _topthreshold =
CALCULATE (
VALUES ( '1-DimKPICat'[Upper Threshold] ),
FILTER ( '1-DimKPICat', '1-DimKPICat'[KPIID] = _Measure )
)
VAR _High_is_Good =
SWITCH (
TRUE (),
[_KPI value_Target] < _bottomthreshold, -1,
[_KPI value_Target] > _topthreshold, 1,
[_KPI value_Target] >= _bottomthreshold
&& [_KPI value_Target] <= _topthreshold, 0
)
VAR _Low_is_Good =
SWITCH (
TRUE (),
[_KPI value_Target] < _bottomthreshold, 1,
[_KPI value_Target] > _topthreshold, -1,
[_KPI value_Target] >= _bottomthreshold
&& [_KPI value_Target] <= _topthreshold, 0
)
RETURN
IF ( _measureLowisGood, _Low_is_Good, IF ( _measureHighisGood, _High_is_Good ) )
@gil12 ¿Puede publicar datos de muestra o una imagen de su tabla donde coloca esta medida? Además, ¿cuántas filas tiene esta tabla?
Hola @gil12
La medida no parece demasiado compleja. ¿Es [_KPI value_Target] una medida? Si es así, lo estás invocando muchas veces. Puede simplemente invocarlo una vez y almacenar su resultado en una variable y utilizar esa variable en consecuencia. Lo mismo para [MeasureID Selected]. Es difícil decir más sin ver el código de esas medidas o más información sobre el modelo de datos. Algo así como:
_KPI Status_Target =
VAR _Measure = [MeasureID Selected] // Measure selected by filter or which is already in a table or a matrix
VAR _measureLowisGood = _Measure IN { 1, 2, 3 } // List all the measures where if the actual value if below target is considered good (example - Lost time Injuries)
VAR _measureHighisGood = _Measure IN { 6, 4, 5 } // List all the measures where if the actual value if above target is considered good (example - OTP)
VAR _bottomthreshold =
CALCULATE (
VALUES ( '1-DimKPICat'[Lower Threshold] ),
FILTER ( '1-DimKPICat', '1-DimKPICat'[KPIID] = _Measure )
)
VAR _topthreshold =
CALCULATE (
VALUES ( '1-DimKPICat'[Upper Threshold] ),
FILTER ( '1-DimKPICat', '1-DimKPICat'[KPIID] = _Measure )
)
VAR var_KPI_value_Target_ = [_KPI value_Target] //CReate this variable to invoke the measure only once
VAR _High_is_Good =
SWITCH (
TRUE (),
var_KPI_value_Target_ < _bottomthreshold, -1,
var_KPI_value_Target_ > _topthreshold, 1,
var_KPI_value_Target_ >= _bottomthreshold
&& var_KPI_value_Target_ <= _topthreshold, 0
)
VAR _Low_is_Good =
SWITCH (
TRUE (),
var_KPI_value_Target_ < _bottomthreshold, 1,
var_KPI_value_Target_ > _topthreshold, -1,
var_KPI_value_Target_ >= _bottomthreshold
&& var_KPI_value_Target_ <= _topthreshold, 0
)
RETURN
IF ( _measureLowisGood, _Low_is_Good, IF ( _measureHighisGood, _High_is_Good ) )
Por favor, marque la pregunta resuelta cuando haya terminado y considere dar felicitaciones si los mensajes son útiles.
Salud
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
1 |