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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Subtract Between Rows with Same ID

Hi Team,

I want to subtract rows with the same Id. Example is what i'm highlighting. Some TaskIDs are unique, some don't.

Unique TaskID: We don't do anything.

NOT Unique TaskId, i want to subtract "TaskBaselineDuration" of BaselineNumber = 0 for BaselineNumber = 1 (they have the same TaskId). Basically i want to know the difference between Baseline 1 and Baseline 0 if it has Baseline. 

 

Desired Result is: TaskBaselineDuration for IDs highlighting: (2064-4529)=-2465 or (1855-8)= 1847

i read many similar posts but couldn't find solution. Thanks

 

emma2002_0-1609031458371.png

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Anonymous 

Not sure if one ID will have only one baseline 1 or 0. if so ,you can try to create a new column.

Column = MAXX(FILTER('Table1',Table1[Task ID]=EARLIER(Table1[Task ID])&&Table1[baseline]=0),Table1[TaskBaselineDuration])-Table1[TaskBaselineDuration]

1.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

First of all, pay attention to your yellow mark is wrong. According to your description, you want to get the value of 1,0 corresponding to TaskBaselineDuration column corresponding to row subtraction under the same TaskID column. I did the following test to create the Subtract_ Result measure: if the ID is the same and the BaselineNumber is 1,0, then the corresponding rows in the TaskBaselineDuration column will be subtracted, otherwise the value will not change.

v-henryk-mstf_1-1609209535425.png

Here is the sample pbix file.


Best Regards,
Henry

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ryan_mayu
Super User
Super User

@Anonymous 

Not sure if one ID will have only one baseline 1 or 0. if so ,you can try to create a new column.

Column = MAXX(FILTER('Table1',Table1[Task ID]=EARLIER(Table1[Task ID])&&Table1[baseline]=0),Table1[TaskBaselineDuration])-Table1[TaskBaselineDuration]

1.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Thank you so much. Your instructions are awesome and work for my case. 

StefanoGrimaldi
Resident Rockstar
Resident Rockstar

I assume you want to subtract the values of ID that appear more tham once? from the total value of the column? lets say total value column minus those 4 highlighted values? or minus only those that have a value of 1 in baseline?

 

if its the second case this simply measure will do: 

Measure = SUM('Table'[value])-CALCULATE(SUM('Table'[value]),'Table'[baseline]<>"0") this should actually work for both cases. (my example measure have baseline as text, if its a number delete the "")




Did I answer your question? Mark my post as a solution! / Did it help? Give some Kudos!

Proud to be a Super User!




Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors