cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors