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,077,822
Messages
5,336,566
Members
399,088
Latest member
Swindlestikz

Some videos you may like

This Week's Hot Topics

Top