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
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 agoNot applicable
Hi nandukrishnavs,,amitchandak ,Anonymous
Thanks for the promt Help with multiple measures :), But in my case all are coming from one table so i tried what Nandu mentioned, but i'm getting nulls, may be i missed complete information what i need.Below is the once which i have showing the screenshot,but i created in Excle, which i'm uanble to write in DAX
Which i want the same as below in Power BI
One with actual values table, and one with % values table ( not having any Actual values )
😞 this is what my second graph should show lik, but i created that in excel,
In my case i want that should be written in Dax 😞
Thanks,
Rams
- nandukrishnavs6 years ago
Community Champion
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 🙂- Anonymous6 years agoNot applicable
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 🙂