Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi guys,
I want to make this change in Query and not on the table in Desktop view:
I have a table as attached here, it has multiple values in "Point Name" columns, I need to subtract the "Point Value" for each consecutive row (the table is already sorted descendingly on Date & Time). The challenge is this subtraction needs to be applied on each "Point Name" separately as they are indicating separate meters. I need to know how to write the M code whilst adding a new column.
Many thanks
Solved! Go to Solution.
Add an index from 0, then create the following custom column, and remember replace error and change data type.
if ([Meter] = #"Added Index"{[Index]+1} [Meter]) then ([Reading]- #"Added Index"{[Index]+1} [Reading]) else ""
Check attached pbix for detail.
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
Add an index from 0, then create the following custom column, and remember replace error and change data type.
if ([Meter] = #"Added Index"{[Index]+1} [Meter]) then ([Reading]- #"Added Index"{[Index]+1} [Reading]) else ""
Check attached pbix for detail.
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
Hi,
This solution is so clever and I used it in Power query however, exactly the same 'step' seems not to work in 'dataflow' and the 'new column' returns 'error'. any idea why the same command does not work in dataflow? thanks
@Alirezam , I am assuming you need the previous row. Check if this article can help
if not
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Hi,
Thanks but this is not answering what I asked. Here is the table I have and the 'Diff' column is what I want to create. As you see, the function of difference should apply for each 'Meter' separately.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
71 | |
57 | |
38 | |
36 |
User | Count |
---|---|
81 | |
67 | |
61 | |
46 | |
45 |