Share via

Excel Power Query: custom column with difference from previous month

Anonymous
2022-07-25T20:15:13+00:00

Hi,

I have a set of data where where I need to add a column with the change in volume from the previous month for each Customer and for each Lane. I attached a photo to help demonstrate what I mean. Is there any way to create a custom column with the values being the difference in volume from the previous month for that particular customer and lane?

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Lz365 38,201 Reputation points Volunteer Moderator
2022-07-26T11:52:10+00:00

Hi

If you must do it in Power Query here is one way (can be slow if you have thousandssss of records) assuming:

  • The step before adding your column is ChangedTypes
  • Your [Date]s are always month/01/year (as in your pic.) otherwise an ajdustment is required

Corresponding sample available here

Note: I've taken the freedom to revise the title of this thread to better reflect the challenge (can help those who search)

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2022-07-26T04:49:17+00:00

    IMHO a simple Pivot table is enough to answer this.

    Sample file

    https://www.dropbox.com/s/a1izxk0qgs6y0qz/9e22fdf7-02d8-4e4c-a1a6-c88486852b65.xlsx?dl=1

    Andreas.

    Was this answer helpful?

    0 comments No comments
  2. Ashish Mathur 102K Reputation points Volunteer Moderator
    2022-07-25T23:16:44+00:00

    Hi,

    I believe it is easier to do this calculation in the Data Model. So you should load this data to the Data Model and then write a calculated column formula to get your desired result. If you really want to stick to a Query Editor solution, then too this can be done but will not be as easy as the Data Model solution.

    Either ways, share the download link of your MS Excel file and in a worksheet show your expected result very clearly.

    Was this answer helpful?

    0 comments No comments