Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ramshoney1225
Helper V
Helper V

Percentage YOY calculation based on columns available in Table

HI I have to calcualte % values for each year with the combination of Company available in a Pivot table and that measure should calcuate dynamically when i pull in Pivot table.

 

Yoy Image.PNG

Ex: for year 2019 ( apple ) =  (Apple 2019 Headcount ) - (Apple 2018 Headcount) / (Apple 2018 Headcount )

                                           =  ( 106700 - 105800 ) / 105800       --> Nearly 1% 

                   2018 ( apple ) =  (Apple 2018 Headcount ) - (Apple 2017 Headcount) / (Apple 2017 Headcount )

                                          =  (105800 - 106400) / 106400          --> Nearly  -1%

                  2017 ( apple ) =  (Apple 2017 Headcount ) - (Apple 2016 Headcount) / (Apple 2016 Headcount )

                   2016 ( apple) = ( Should be blank of not having 2015 Head count data ) 

 

Simillary, same calucation should happend for NOkia, Samsung.

 

How to do that dynamic calcuation with only one measure i need to create ?

 

Actaully i'm unabl to upload the PBIX file, didnt see option to upload but the data is this only .

 

CompanyYearHeadcount
Apple2019106700
Apple2018105800
Apple2017106400
Apple2016102500
Samsung201992005
Samsung2018103564
Samsung2017105870
Samsung2016104553
Nokia2019146768
Nokia2018150711
Nokia2017152000
Nokia2016155000

 

THanks,

Rams

2 ACCEPTED SOLUTIONS
nandukrishnavs
Super User
Super User

@ramshoney1225 

 

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

 

Capture.JPG



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂


Regards,
Nandu Krishna

View solution in original post

harshnathani
Community Champion
Community Champion

Hi @ramshoney1225 ,

 

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))

RETURN

DIVIDE(MAX('Table'[Headcount]) - _previousYearHeadcount,_previousYearHeadcount)
 
1.jpg
 
2.JPG
 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

View solution in original post

10 REPLIES 10

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.