Forum Discussion
Percentage YOY calculation based on columns available in Table
- 6 years ago
Anonymous
Try this DAX measure
Percentage YOY = VAR _currentYear = SELECTEDVALUE ( 'Table'[Year] ) VAR _company = SELECTEDVALUE ( 'Table'[Company] ) VAR _current = SUM ( 'Table'[Headcount] ) VAR _prior = SUMX ( FILTER ( ALL ( 'Table'[Company], 'Table'[Headcount], 'Table'[Year] ), ( 'Table'[Year] = _currentYear - 1 ) && ( 'Table'[Company] = _company ) ), 'Table'[Headcount] ) VAR _yoy = DIVIDE ( _current - _prior, _prior, BLANK () ) RETURN _yoy
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂 - Anonymous6 years ago
Hi Anonymous ,
You can use the below measure
Previous Year Headcount % =Var _max = MAX ('Table'[Year])Var _previousYear = CALCULATE( MAX('Table'[Year]), FILTER(ALL('Table'), 'Table'[Year] < _max && 'Table'[Company] = MAX('Table'[Company])))Var _previousCompany = CALCULATE( MAX('Table'[Company]), FILTER(ALL('Table'), 'Table'[Year] < _max && 'Table'[Company] = MAX('Table'[Company])))var _previousYearHeadcount = CALCULATE( MAX('Table'[Headcount]), FILTER(ALL('Table'), 'Table'[Year] = _previousYear && 'Table'[Company] = _previousCompany))RETURNDIVIDE(MAX('Table'[Headcount]) - _previousYearHeadcount,_previousYearHeadcount)Regards,
Harsh NathaniDid I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)
Hi Anonymous , nandukrishnavs
Thanks for the help, the both measures works as expected shared by you 🙂
As intial i got response from nandukrishnavs , will make as "accept solution" if it allows 2 then will make Anonymous as well.
Before closing this, how to get master in DAX 😞 , any helpful links will be highly appreciated.
Actually i'm sturggle lot to write a DAX 😞 😞 😞
Thanks alot.
Hi amitchandak
Thanks for sharing more information if it was in differnt tables.
Thanks,
Rams