Forum Discussion
Comparing values to earlier values.
- 8 years ago
Hi Anonymous,
Please try to add calculated columns with below DAX:
past = LOOKUPVALUE ( Tb2[Values], Tb2[Names], Tb2[Names], Tb2[Dates], CALCULATE ( MAX ( Tb2[Dates] ), FILTER ( ALLEXCEPT ( Tb2, Tb2[Names] ), Tb2[Dates] < EARLIER ( Tb2[Dates] ) ) ) ) growth = IF ( Tb2[past] = BLANK (), 0, ( Tb2[Values] - Tb2[past] ) / Tb2[past] )
And then monthly - however some months dont have data - empty. Is there a way to treat those empty months as 0? And then show current month growth as 0? With the last growth figure by its side - with the last growth date?I cannot understand above requirement well, please illustrate your desired result with more details.
Best regards,
Yuliana Gu
Hi Anonymous,
Please try to add calculated columns with below DAX:
past =
LOOKUPVALUE (
Tb2[Values],
Tb2[Names], Tb2[Names],
Tb2[Dates], CALCULATE (
MAX ( Tb2[Dates] ),
FILTER ( ALLEXCEPT ( Tb2, Tb2[Names] ), Tb2[Dates] < EARLIER ( Tb2[Dates] ) )
)
)
growth =
IF ( Tb2[past] = BLANK (), 0, ( Tb2[Values] - Tb2[past] ) / Tb2[past] )
And then monthly - however some months dont have data - empty. Is there a way to treat those empty months as 0? And then show current month growth as 0? With the last growth figure by its side - with the last growth date?
I cannot understand above requirement well, please illustrate your desired result with more details.
Best regards,
Yuliana Gu
When trying the dataset which is computed manually v-yulgu-msft it works like a charm! But the issue still persists with that error in a normal table.
Thank you for your response v-yulgu-msft, however the callculated collumn shows me this error.
"A table of multiple values was supplied when a single value was expected"
Could the issue be that my NAMES (company) are related from another collumn and my vallues(margin real) are callculated collumn as well?
Regarding the monthly growth what I would like to do is a moving average of monthly/ 3 months/ 6 months.
I think I know how to do it (DAX below). But would like to do it by the Company (NAMES in your pbix). Not that advanced in DAX when it comes towards this.
Moving 3 AVG =
CALCULATE (
AVERAGE ( Orders[Margin Real] );
DATESINPERIOD (
Orders[actual_delivery_date];
LASTDATE ( Orders[actual_delivery_date] );
-3;
MONTH
)
)
Thank you for your help and time v-yulgu-msft.