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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
sperry
Resolver I
Resolver I

Calculated percentage change based on sum of a text category

I have a population projection dataset which I receive from a govnt agency. Sample below;

 

Update YearRegionDHB_nameSexEthnicityethnicity2Age_GroupPeriodPeriod TypePopulationPeriod Index
2017OtherAucklandFemaleAsianOther00-042013Annual37001
2017OtherAucklandFemaleAsianOther00-042014Annual36302
2017OtherAucklandFemaleAsianOther00-042015Annual37703
2017OtherAucklandFemaleAsianOther00-042016Annual39904
2017OtherAucklandFemaleAsianOther00-042017Annual42905
2017OtherAucklandFemaleAsianOther00-042018Annual45706
2017OtherAucklandFemaleAsianOther00-042019Annual50207
2017OtherAucklandFemaleAsianOther00-042020Annual53808
2017OtherAucklandFemaleAsianOther00-042013_2014Financial36601
2017OtherAucklandFemaleAsianOther00-042014_2015Financial37002
2017OtherAucklandFemaleAsianOther00-042015_2016Financial38803
2017OtherAucklandFemaleAsianOther00-042016_2017Financial41404
2017OtherAucklandFemaleAsianOther00-042017_2018Financial44305
2017OtherAucklandFemaleAsianOther00-042018_2019Financial48006

 

I want to create a measure that will allow me to calculate % Population change using the Period as the visual axis. Period comes as a text field so I created the Period Index. The visual will always have Period Type filter set to either Annual or Financial

 

Here is link to the pbix Population Data for full data set.

 

Any help gratefully received

 

2 ACCEPTED SOLUTIONS
v-lili6-msft
Community Support
Community Support

hi, @sperry

After my test on your sample data, you could use this formula to add a measure:

Measure = 
VAR __Perindex =
    CALCULATE (
        SUM ( 'Table'[Population] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[Period Type] ),
            'Table'[Period Index]
                = MAX ( 'Table'[Period Index] ) - 1
        )
    )
RETURN
    DIVIDE ( SUM ( 'Table'[Population] ) - __Perindex, __Perindex )

By the way: If you want to add other fields as group, add them to the red font section.

https://www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept...

 

Result:

4.JPG

and here is pbix file, please try it.

 

Best Regards,

Lin

 

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

hi, @sperry

You could get it by the same logic,

if the format of [Period] column is a number, you could use formula like this:

 

Measure = 
VAR __Perindex =
    CALCULATE (
        SUM ( 'Table'[Population] ),
        FILTER (
            ALL ( 'Table'),
            'Table'[Period]
                = MAX ( 'Table'[Period] ) - 1
        )
    )
RETURN
    DIVIDE ( SUM ( 'Table'[Population] ) - __Perindex, __Perindex )

Else you need to add another index column

Period Period Index Population Population Change from Base new index
2013 1 200   1
2014 3 300 50.00% 2
2015 4 350 75.00% 3
2016 5 400 100.00% 4
2017 6 450 125.00% 5

 

and then use new index column for calculation.

 

Best Regards,
Lin

 

 

 

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-lili6-msft
Community Support
Community Support

hi, @sperry

After my test on your sample data, you could use this formula to add a measure:

Measure = 
VAR __Perindex =
    CALCULATE (
        SUM ( 'Table'[Population] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[Period Type] ),
            'Table'[Period Index]
                = MAX ( 'Table'[Period Index] ) - 1
        )
    )
RETURN
    DIVIDE ( SUM ( 'Table'[Population] ) - __Perindex, __Perindex )

By the way: If you want to add other fields as group, add them to the red font section.

https://www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept...

 

Result:

4.JPG

and here is pbix file, please try it.

 

Best Regards,

Lin

 

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Excellent thanks for this..have added the groups as suggested.

One additional query. Is there a way of adding a base year (ie. Period Index = 1) and doing a calculated change from that point? To give something like this?

 

PeriodPeriod IndexPopulationPopulation Change from Base
20131200 
2014330050.00%
2015435075.00%
20165400100.00%
20176450125.00%

hi, @sperry

You could get it by the same logic,

if the format of [Period] column is a number, you could use formula like this:

 

Measure = 
VAR __Perindex =
    CALCULATE (
        SUM ( 'Table'[Population] ),
        FILTER (
            ALL ( 'Table'),
            'Table'[Period]
                = MAX ( 'Table'[Period] ) - 1
        )
    )
RETURN
    DIVIDE ( SUM ( 'Table'[Population] ) - __Perindex, __Perindex )

Else you need to add another index column

Period Period Index Population Population Change from Base new index
2013 1 200   1
2014 3 300 50.00% 2
2015 4 350 75.00% 3
2016 5 400 100.00% 4
2017 6 450 125.00% 5

 

and then use new index column for calculation.

 

Best Regards,
Lin

 

 

 

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors