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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
DebbieK
Helper I
Helper I

Iterating and comparing rows

I have a table of tasks assigned to different people, with set due dates, hours and priorities. I have previously processed these (in Visual Studio) to determine an order of works. This was done by

  1. Grouping tasks by person
  2. Ranking by due date
  3. Determining projected completion dates, based on the sum of the hours of tasks ranked above them, then
  4. Iterating the rankings from first to last and checking whether the due date was being met
  5. If yes no action was taken
  6. If no it was checked whether this task was a higher priority than the task ranked above, if so its rank was switched with the one above and projected end dates recalculated until it was either meeting due date or was not a higher priority than the task above (essentially moving it up the rankings).

I am new to PowerBI and am trying to follow the same logic but can't figure out how to iterate, with reference to other rows. Can anyone assist with the best way to approach this?

 

Sample data 

AssignedToIDDue DatePriority (999 = highest)WorkingDaysRemaining
51/08/20222005
61/08/20221005
75/08/20221007
710/08/20221004
613/08/20225005
515/08/202290010
615/08/20225005
520/08/20225005
730/08/20229002

 

Desired result

 

AssignedToIDDue DatePriority (999 = highest)WorkingDaysRemainingRankProjectedEndDateOntime
515/08/202290010115/08/2022Y
520/08/20225005222/08/2022N
51/08/20222005329/08/2022N
613/08/2022500518/08/2022Y
615/08/20225005215/08/2022Y
61/08/20221005320/08/2022N
75/08/20221007116/08/2022N
710/08/20221004222/08/2022N
730/08/20229002324/08/2022Y
8 REPLIES 8
danextian
Super User
Super User

Hi @DebbieK ,

 

I am honestly confused with the sample and expected results provided. The due dates don't match as well as the priorities. For ID5, the dates are all 1/8 in the sample data but they're different in the expected result except for one. The priority numbers are also different - {900,500,100} vs {900,500,200} 

 

danextian_0-1660792805363.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi Danextian - thank you, and sorry for the mistake in the sample data, one of the due dates were wrong. I have now corrected this.

 

Note in the sample data it is sorted by due date, in the output data it is grouped by ID and then sorted by rank. 

Hello,

Where can I find the hours?

Determining projected completion dates, based on the sum of the hours of tasks ranked above them

 

Also, how is the projected end date computed? I am assuming that it is 7 (x rank-1) days from rank1 project.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi danextian - thanks for your help. 

 

The hours = 8 hours x number of working days. 

 

The projected completion date is the end of the previously ranked project + working days. For example ID 5, top ranked project finishes on 15/08/22. ID 5 second ranked project then has a completion date of 15/8/22 + 5 working days being 22/8/22 (due to weekend days). 

I am confused how the rank is calculated. For ID5, it appears that they're ranked by priority. For 7, they are ranked by Due Date.

danextian_0-1660807726953.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi danextian,

The logic is to rank by due date, then check if a higher prioirity task is not ontime and if so promote it up the ranks.

 

For ID 7 they are ranked by due date, and the higher priority task is on time, so no changes are needed.

 

I've played out the example process for ID 5 below.

 

STEP 1 - Sort by due date 

AssignedToIDDue DatePriority (999 = highest)WorkingDaysRemaining
51/08/20222005
515/08/202290010
520/08/20225005
61/08/20221005
613/08/20225005
615/08/20225005
75/08/20221007
710/08/20221004
730/08/20229002

 

STEP 2 - Iterate and check whether on time, promote if needed. 

EG.

Row 2, ONTIME = N, so check whether Row 2 is a higher priority than Row 1. 

900 > 200 so move Row 2 up rank. 

 

      
AssignedToIDDue DatePriority (999 = highest)WorkingDaysRemainingProjectedEndDate
 

 

Ontime
51/08/202220058/08/2022N
515/08/20229001022/08/2022N
520/08/2022500529/08/2022N
61/08/202210058/08/2022N
613/08/2022500515/08/2022N
615/08/2022500522/08/2022Y
75/08/2022100710/08/2022N
710/08/2022100416/08/2022N
730/08/2022900218/08/2022Y

 

Then EG 

Row 3, ONTIME = N, so check whether Row 3 is higher priority than Row 2.

Priority 500> 200, so move Row 3 up rank

ONTIME still = No

Check whether higher priority than Row 1

Priority 500 < 900 so do not move higher.

 

      
AssignedToIDDue DatePriority (999 = highest)WorkingDaysRemainingProjectedEndDateOntime
515/08/20229001015/08/2022Y
51/08/2022200522/08/2022
 

 

N
520/08/2022500529/08/2022N
61/08/202210058/08/2022N
613/08/2022500515/08/2022N
615/08/2022500522/08/2022Y
75/08/2022100710/08/2022N
710/08/2022100416/08/2022N
730/08/2022900218/08/2022Y

 

Finished iteration of ID5 

       
AssignedToIDDue DatePriority (999 = highest)WorkingDaysRemainingRankProjectedEndDateOntime
515/08/202290010115/08/2022Y
520/08/20225005222/08/2022N
51/08/20222005329/08/2022N
61/08/20221005 8/08/2022N
613/08/20225005 15/08/2022N
615/08/20225005 22/08/2022Y
75/08/20221007 10/08/2022N
710/08/20221004 16/08/2022N
730/08/20229002 18/08/2022Y

 

 

In step 2, how would one know whether a project is on-time or not? Also in row 2, 15/8 + 10 workdays shouldn't that be 29/8?





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

If ProjectedEndDate is on or before DueDate than the project is ontime

 

Take "TODAY" as 1 August. For example in Step 2 (screenshot below)

- Row one is 5 days and so ProjectedEndDate is 8 August

- Row two is 10 days and so ProjectedEndDate is 10 working days AFTER the end date of Row 1 (so 8 August + 10wd = 22 August)

 

DebbieK_0-1661303040325.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.