Forum Discussion
last value with conditional (zero)
- 7 years ago
Hi igorabdo
If you want to have the average at the total there are two possibilities. I'm not sure which one you prefer.
One is that we take the average with the original zeros (i.e. without the filled-in values). Note that we are using the [Mesure_CUSTO] defined previously. You don't need to use it in the visual any longer but do keep the definition.
Measure_CUSTO_With_Avg@TotalWithOriginalZeros = IF ( ISFILTERED ( Table1[Mês Ano] ); [Measure_CUSTO]; AVERAGEX ( ADDCOLUMNS ( SUMMARIZE ( Table1; Table1[ITEMID]; Table1[Mês Ano] ); "Result"; CALCULATE ( SUM ( Table1[CUSTO] ) ) ); [Result] ) )
Not trivial. You have to use an explicit measure instead of relying on an implicit one. Create this measure and place it in the table visual:
Measure_CUSTO =
VAR _LatestNonZeroDate =
CALCULATE (
MAX ( Table1[Mês Ano] );
FILTER (
ALL ( Table1[Mês Ano] );
Table1[Mês Ano] <= SELECTEDVALUE ( Table1[Mês Ano] )
&& CALCULATE ( SUM ( Table1[CUSTO] ) ) <> 0
)
)
RETURN
CALCULATE (
SUM ( Table1[CUSTO] );
Table1[Mês Ano] = _LatestNonZeroDate
)
It's perfect AlB
The measure it's amazing.
The last question
If I want an average in the final?
But don't worry. Your measure is perfect
- AlB7 years agoCommunity Champion
Hi igorabdo
If you want to have the average at the total there are two possibilities. I'm not sure which one you prefer.
One is that we take the average with the original zeros (i.e. without the filled-in values). Note that we are using the [Mesure_CUSTO] defined previously. You don't need to use it in the visual any longer but do keep the definition.
Measure_CUSTO_With_Avg@TotalWithOriginalZeros = IF ( ISFILTERED ( Table1[Mês Ano] ); [Measure_CUSTO]; AVERAGEX ( ADDCOLUMNS ( SUMMARIZE ( Table1; Table1[ITEMID]; Table1[Mês Ano] ); "Result"; CALCULATE ( SUM ( Table1[CUSTO] ) ) ); [Result] ) )- AlB7 years agoCommunity Champion
The other option is that we take the average with the filled-in values. Again, we are using the [Mesure_CUSTO] defined previously.
Let me know if this solves the issue.
Measure_CUSTO_With_Avg@TotalWithFilledValues2 = AVERAGEX ( ADDCOLUMNS ( SUMMARIZE ( Table1; Table1[ITEMID]; Table1[Mês Ano] ); "Result"; [Measure_CUSTO] ); [Result] )