Forum Discussion
Forecasting is not summing up
- Anonymous8 years ago
Hi pfuschi,
If you mean look up suitable records based on year and age, you can refer to below steps.
1. Create a table stored year and not has relationship to original table.
Year Range = GENERATESERIES(2010,2040,1)
2. Create matrix visual with age as row(original table), year as column(year range table), lookupvalue measure as value.
Look up = VAR currAge = LASTNONBLANK ( 'Sample'[Age], [Age] ) VAR currYear = SELECTEDVALUE ( 'Year Range'[Year] ) VAR lookup = LOOKUPVALUE ( 'Sample'[Count], 'Sample'[Age], currAge, 'Sample'[Year], currYear ) RETURN IF ( lookup <> BLANK (), lookup )3. Modify measure to add bin variable to store diff between year and age, use this variable to lookup value from previous records.
Look up 2 = VAR currAge = LASTNONBLANK ( 'Sample'[Age], [Age] ) VAR currYear = SELECTEDVALUE ( 'Year Range'[Year] ) VAR lookup = LOOKUPVALUE ( 'Sample'[Count], 'Sample'[Age], currAge, 'Sample'[Year], currYear ) VAR bin = currYear - currAge RETURN IF ( lookup <> BLANK (), lookup, CALCULATE ( MAX ( 'Sample'[Count] ), FILTER ( ALL ( 'Sample' ), [Year] - [Age] = bin ) ) + 0 )BTW, if you want to summarize all suitable records, please use sum function to replace max function which I used in if statement.
Regards,
Xiaoxin Sheng
Hi pfuschi,
If you mean look up suitable records based on year and age, you can refer to below steps.
1. Create a table stored year and not has relationship to original table.
Year Range = GENERATESERIES(2010,2040,1)
2. Create matrix visual with age as row(original table), year as column(year range table), lookupvalue measure as value.
Look up =
VAR currAge =
LASTNONBLANK ( 'Sample'[Age], [Age] )
VAR currYear =
SELECTEDVALUE ( 'Year Range'[Year] )
VAR lookup =
LOOKUPVALUE (
'Sample'[Count],
'Sample'[Age], currAge,
'Sample'[Year], currYear
)
RETURN
IF (
lookup <> BLANK (),
lookup
)
3. Modify measure to add bin variable to store diff between year and age, use this variable to lookup value from previous records.
Look up 2 =
VAR currAge =
LASTNONBLANK ( 'Sample'[Age], [Age] )
VAR currYear =
SELECTEDVALUE ( 'Year Range'[Year] )
VAR lookup =
LOOKUPVALUE (
'Sample'[Count],
'Sample'[Age], currAge,
'Sample'[Year], currYear
)
VAR bin = currYear - currAge
RETURN
IF (
lookup <> BLANK (),
lookup,
CALCULATE (
MAX ( 'Sample'[Count] ),
FILTER ( ALL ( 'Sample' ), [Year] - [Age] = bin )
)
+ 0
)
BTW, if you want to summarize all suitable records, please use sum function to replace max function which I used in if statement.
Regards,
Xiaoxin Sheng