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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Meghbajaj
Frequent Visitor

Percentage Change and Value Difference

Hi Everyone, I am trying to calculate Percentage Change and Value Difference group by ID in the Power BI report. Please suggest the optimal way to do it. Thanks a lot.

 

Original Table:

IDSalaryEffective DateEnd Date
100150001/04/201825/07/2018
100170026/07/201818/03/2019
100185019/03/201931/12/2999
1002110016/07/201931/12/2999
1003150001/05/201931/12/2019
1003175001/01/202031/12/2999

 

Result Table:

IDSalaryEffective DateEnd DateSalary ChangePercent Change

1001

50001/04/201825/07/201800
100170026/07/201818/03/201920040
100185019/03/201931/12/299915021.4
1002110016/07/201931/12/299900
1003150001/05/201931/12/201900
1003175001/01/202031/12/299925016.66

 

 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Meghbajaj 

try to add two columns like this:

Salary Change 2 = 
VAR _id = [ID]
VAR _date = [Effective Date]
VAR _table =
FILTER(TableName, TableName[ID]=_id)
VAR _datepre =
MAXX(
    FILTER(_table, TableName[Effective Date]<_date),
    TableName[Effective Date]
)
VAR _salarypre =
MINX(
    FILTER(_table, TableName[Effective Date]=_datepre),
    TableName[Salary]
)
RETURN
IF( _salarypre<>BLANK(), [Salary] - _salarypre)

Percent Change  2 = 
VAR _id = [ID]
VAR _date = [Effective Date]
VAR _table =
FILTER(TableName, TableName[ID]=_id)
VAR _datepre =
MAXX(
    FILTER(_table, TableName[Effective Date]<_date),
    TableName[Effective Date]
)
VAR _salarypre =
MINX(
    FILTER(_table, TableName[Effective Date]=_datepre),
    TableName[Salary]
)
RETURN
IF( _salarypre<>BLANK(), DIVIDE( [Salary] - _salarypre, _salarypre))

 

it worked like this:

FreemanZ_0-1672980102431.png

View solution in original post

1 REPLY 1
FreemanZ
Super User
Super User

hi @Meghbajaj 

try to add two columns like this:

Salary Change 2 = 
VAR _id = [ID]
VAR _date = [Effective Date]
VAR _table =
FILTER(TableName, TableName[ID]=_id)
VAR _datepre =
MAXX(
    FILTER(_table, TableName[Effective Date]<_date),
    TableName[Effective Date]
)
VAR _salarypre =
MINX(
    FILTER(_table, TableName[Effective Date]=_datepre),
    TableName[Salary]
)
RETURN
IF( _salarypre<>BLANK(), [Salary] - _salarypre)

Percent Change  2 = 
VAR _id = [ID]
VAR _date = [Effective Date]
VAR _table =
FILTER(TableName, TableName[ID]=_id)
VAR _datepre =
MAXX(
    FILTER(_table, TableName[Effective Date]<_date),
    TableName[Effective Date]
)
VAR _salarypre =
MINX(
    FILTER(_table, TableName[Effective Date]=_datepre),
    TableName[Salary]
)
RETURN
IF( _salarypre<>BLANK(), DIVIDE( [Salary] - _salarypre, _salarypre))

 

it worked like this:

FreemanZ_0-1672980102431.png

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Kudoed Authors