Forum Discussion
Add rows for misisng years
- 4 years ago
Hi, Anonymous
Create a calculation table as follows:T = var _t=ADDCOLUMNS('Table',"maxTo",[_Max],"minTo",[_min]) var _id_to=SUMMARIZE(_t,'Table'[MembershipID],'Table'[MembershipGroup],[maxTo],[minTo]) var _id=SUMMARIZE('Table','Table'[MembershipID],'Table'[MembershipGroup]) var _maxOfAll=Value([_Max]) var _minOfAll=Value([_min]) var _GenerateTable=GENERATE(_id,GENERATESERIES(_minOfAll,_maxOfAll)) var _Fact=FILTER(_GenerateTable,[MembershipID]='Table'[MembershipID]&&[MembershipGroup]='Table'[MembershipGroup]&& ''[Value]<=MAXX(FILTER(_id_to,[MembershipID]=EARLIER([MembershipID])&&[MembershipGroup]=EARLIER([MembershipGroup])),Value([maxTo]))&&''[Value]>=MINX(FILTER(_id_to,[MembershipID]=EARLIER([MembershipID])&&[MembershipGroup]=EARLIER([MembershipGroup])),Value([minTo]))&&Value(RIGHT(CONVERT(''[Value],STRING),2))<=12&&Value(RIGHT(CONVERT(''[Value],STRING),2))>=1 ) return _FactCreate 2 measures to get the maximum year-month and the minimum year-month.
_Max = CALCULATE(MAX('Table'[InceptionDate(YYYYMM)]),ALLEXCEPT('Table','Table'[MembershipID],'Table'[MembershipGroup]))_min = CALCULATE(MIN('Table'[InceptionDate(YYYYMM)]),ALLEXCEPT('Table','Table'[MembershipID],'Table'[MembershipGroup]))Finally create a calculated column to get the result.
Account = var _account= LOOKUPVALUE('Table'[AccountBalance],'Table'[MembershipID],[MembershipID],'Table'[MembershipGroup],[MembershipGroup],'Table'[InceptionDate(YYYYMM)],CONVERT([Value],STRING)) var _table= FILTER(ALL('Table'), 'Table'[MembershipID]=EARLIER(T[MembershipID]) &&'Table'[MembershipGroup]=EARLIER(T[MembershipGroup]) &&Value('Table'[InceptionDate(YYYYMM)])<=EARLIER([Value]) ) var _fillDown= CALCULATE( Min('Table'[AccountBalance]), _table ) var _ifBlank=IF(ISBLANK(_account),_fillDown,_account) return _ifBlank
Result:Please refer to the attachment below for details. Hope this helps.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is possible but are you sure you'd like to add rows to your dataset? If the goal is to show balances for x items as of a certian date, there are ways to handle this with a dax measure so that you don't have to increase your dataset size.
Yes. In particular, having a proper date dimension table to work with should eliminate the need to expand your dataset