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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

DAX to calculate relative and total percentage growth based on multiple time selections

I'm trying to calculate few DAX measure to calculate the total balance change between two selected time periods for different codes. The possible outcome would look like:

 

parag123_2-1617370315362.png

 

 

I have calculated the first 4 DAX measure as follows:

 

 

 

Time Period 1 = VAR _d1 = MIN(data[Date])
RETURN CALCULATE(SUM(data[Balance]), ALLEXCEPT(data,data[Code]),DATESINPERIOD(data[Date], _d1, -6, MONTH)) - CALCULATE(SUM(data[Balance]), ALLEXCEPT(data,data[Code]),DATESINPERIOD(data[Date], _d1, -3, MONTH))
Time Period 2 = VAR _d1 = MAX(data[Date])
RETURN CALCULATE(SUM(data[Balance]), ALLEXCEPT(data,data[Code]),DATESINPERIOD(data[Date], _d1, -6, MONTH)) - CALCULATE(SUM(data[Balance]), ALLEXCEPT(data,data[Code]),DATESINPERIOD(data[Date], _d1, -3, MONTH))
Growth = [Time Period 2]-[Time Period 1]
% Growth = DIVIDE([Growth],[Time Period 2])

 

 

 

 

I created the following DAX for total growth:

 

 

 

Total Growth = var _d1 = MAX(data[Date])
RETURN CALCULATE([% Growth], data[Date]=_d1,ALL(data))

 

 

 

 

But I'm sure something's wrong with the formula as I'm not getting any values: 

parag123_3-1617370421660.png

 

Theoritically 'total growth' is simply the overall growth for all the codes combined(23.21%) in this case which in turn is used to calculate 'relative growth' = % growth - total growth. I'm not able to capture the total growth primarily because it's calculated based on 2 time periods.

 

Please suggest appropriate modifications to the DAX.

 

Link to pbix for reference: https://drive.google.com/file/d/14P9YxYbYqEFZ8VSk7cLuR1li4b6g5m9q/view?usp=sharing

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

I am not sure if I understood correctly, but do you want to show 23.21% for all rows, including the total?

Then, try the below, 

 

CALCULATE([% Growth], ALLSELECTED(data[Code]))
 
Sorry for my poor understanding.
 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

I am not sure if I understood correctly, but do you want to show 23.21% for all rows, including the total?

Then, try the below, 

 

CALCULATE([% Growth], ALLSELECTED(data[Code]))
 
Sorry for my poor understanding.
 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Anonymous
Not applicable

Thanks a lot @Jihwan_Kim this worked like a charm. I always get confused with the 'ALL' function family.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.