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)
Anonymous You have to create a DAX measure. I think you have created a calculated column.
I tried your sample data, it is working for me. You can find the snapshot in my original post.
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂
Ya, I created calculated columns :|.
My assumption is wrong , i though that it will do row by row SUMX used and i created a calculated column.
Ok will create that in measure, let you know 🙂