Lopp through table like macro????

SAMCRO2014

Board Regular
Joined
Sep 3, 2015
Messages
141
I am trying to figure out if you can loop through data in the table in power query. Here is my scenario. I have employees who receive a bilingual bonus (BB). This amount gets charged to a cost centre for a specific time frame. The issue comes into play when the BB is charged to two or more CCs for the same time period. I need to be able to do a count of sorts so I can divide the cost evenly over the multiple cost centre for the specific time frame.

I was hoping to create a conditional column with results that show the "Count" column as per below:

CCEE #Start DateEnd DateBBCount
12054432011111112019-04-012019-06-26Yes1
12054432011111112019-06-272019-07-19Yes1
12014720099999992019-04-012019-05-03Yes3
12014720499999992019-04-012019-05-03Yes3
12014720399999992019-04-012019-05-03Yes3
12014720099999992019-05-042019-05-24Yes3
12014720399999992019-05-042019-05-24Yes3
12014720499999992019-05-042019-05-24Yes3
12014720399999992019-05-252019-07-19Yes2
12014720499999992019-05-252019-07-19Yes2

<colgroup><col><col><col span="2"><col><col></colgroup><tbody>
</tbody>
Is this even possible in Power Query?

<colgroup><col><col><col span="2"><col><col></colgroup><tbody>
</tbody>

<colgroup><col><col><col span="2"><col><col></colgroup><tbody>
</tbody>
 

horseyride

Board Regular
Joined
Nov 2, 2017
Messages
81
try below
Its adds a count for rows where EE# and Start Date are the same

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
   Ttl2 = Table.AddColumn(Source, "Count", (i) => List.Count(Table.SelectRows(Source, each ([#"EE #"] = i[#"EE #"] and [Start Date] = i[Start Date]))[#"EE #"]) , type number   )
in Ttl2
 

Forum statistics

Threads
1,078,520
Messages
5,340,922
Members
399,399
Latest member
SravanaSandhya

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top