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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
lokeswer
Helper I
Helper I

Find the Batch sizes listing all batches for product in a day

Hey!

I have a dataset listed by Date/time that shows the production runs by-product throughout a day, the catch is the same product could be made in different batch sizes at different times of the day. 

I am trying to essentially find the largest Batch size & compare times M-O-M, but as a first step trying to calculate the batch sizes at different times of the day. 

 

I tried indexing & ranking but got stuck on how to differentiate the same Product "Batch" as the product name looks identical with only the time stamps being unique

 

wanted it to look more like 

DateProductBatchCount
1/2/2023X539-SA-84.8-0.197A4
1/2/2023X539-SA-64.5-0.126B2
1/2/2023X539-SA-77-0.135C2
1/2/2023X528-SA-77-0.095D2
1/2/2023X621-HS3-73.5-0.197E6
1/2/2023X539-SA-84.8-0.197A4
1/2/20235182-DS-77-0.12F2

 

 

Not sure if there is a better way

 

any help or leads would be much appreciated!

ReceiveTimestampCustom
1/2/2023 0:05X539-SA-84.8-0.197
1/2/2023 0:12X539-SA-84.8-0.197
1/2/2023 0:47X539-SA-84.8-0.197
1/2/2023 1:05X539-SA-84.8-0.197
1/2/2023 1:21X539-SA-64.5-0.126
1/2/2023 1:21X539-SA-64.5-0.126
1/2/2023 1:22X539-SA-77-0.135
1/2/2023 1:57X539-SA-77-0.135
1/2/2023 2:05X528-SA-77-0.095
1/2/2023 2:14X528-SA-77-0.095
1/2/2023 2:46X621-HS3-73.5-0.197
1/2/2023 2:51X621-HS3-73.5-0.197
1/2/2023 2:56X621-HS3-73.5-0.197
1/2/2023 3:02X621-HS3-73.5-0.197
1/2/2023 3:03X621-HS3-73.5-0.197
1/2/2023 3:08X621-HS3-73.5-0.197
1/2/2023 3:21X539-SA-84.8-0.197
1/2/2023 3:29X539-SA-84.8-0.197
1/2/2023 3:39X539-SA-84.8-0.197
1/2/2023 4:32X539-SA-84.8-0.197
1/2/2023 4:385182-DS-77-0.12
1/2/2023 4:495182-DS-77-0.12
1 ACCEPTED SOLUTION

Do you really need to label Batch as A through F given that you already have Product?

 

Just do a normal group by with count and then afterwards adjust the formula and add GroupKind.Local to the end.  GroupKind.Local will only group CONSECUTIVE matching group by columns (unless you do a custom local comarison formula).

 

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ndI5DsJADAXQq6CpM8n4256tQ6KgT4MU5f7XICMWZQFh0T95+54mRwMGBPAp1KCuczfl4sezz9JnH3oqyc3dhhFMTJKBka0pVdCKRem1McR/2XqFlBpi3SNNPxFe4yO/USgHRGJAEhuKIH8d2Sd+zL6/BKqS0ZnqcQ0wOja6bHObqL4Fv7BiYmxhUtnyuwtrOyhl+Mv4jB57I+WTme8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ReceiveTimestamp = _t, Custom = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ReceiveTimestamp", type datetime}, {"Custom", type text}}),
    #"Extracted Text Before Delimiter" = Table.TransformColumns(#"Changed Type", {{"ReceiveTimestamp", each Text.BeforeDelimiter(Text.From(_, "en-US"), " "), type date}}),
    #"Grouped Rows" = Table.Group(#"Extracted Text Before Delimiter", {"ReceiveTimestamp", "Custom"}, {{"Count", each Table.RowCount(_), Int64.Type}}, GroupKind.Local)
in
    #"Grouped Rows"

 

 

 

 

spinfuzer_0-1704223345065.png

 

View solution in original post

9 REPLIES 9
jennratten
Super User
Super User

Can you please explain what is considered to be a "batch"? In the table you provided with the requested outcome, how did you come up with that? 

Hey @jennratten

I considered a batch as a group of items that are made together. e.g like 15 blue shoes, 20 brown shoes,10 yellow, 7 blue(again) throughout the timeline. 

 

for your second question, that's how i envisioned the final data to be, was the question too as to how to group em like that with "batch size" 

So is the sample data you provided all of the records for one batch and you have just omitted the specific columns that are used to identify a batch?

Hey Jenn!

currently the only way to create/label them as batches is looking at the products themselves in "Custom" column. if they are repeating we consider as a batch. There's nothing in data to actually says batch 1, 2, 3. Guess that;s what i was trying to find how to do

 

does that help clarify?

@lokeswer Have you had a chance to review this latest reply? 

I do not believe anyone understands your vision of how to get from your raw data to the final outcome.

 

Go through some specific Examples of Receive, Timestamp, and Custom and how that translates into your final outcome.

 

The custom and timestamp columns are disappearing, and it is hard to understand what happens to them and how they suddenly turn into letters and numbers.

Hey Spinfuzer!

Thanks for your reply. I am not sure I see what disappears.

Both tables are just examples of how data is. 

I consolidated the both together to see if it helps

DateProductBatchCount
1/2/2023X539-SA-84.8-0.197A4
1/2/2023X539-SA-64.5-0.126B2
1/2/2023X539-SA-77-0.135C2
1/2/2023X528-SA-77-0.095D2
1/2/2023X621-HS3-73.5-0.197E6
1/2/2023X539-SA-84.8-0.197A4
1/2/20235182-DS-77-0.12F2

Do you really need to label Batch as A through F given that you already have Product?

 

Just do a normal group by with count and then afterwards adjust the formula and add GroupKind.Local to the end.  GroupKind.Local will only group CONSECUTIVE matching group by columns (unless you do a custom local comarison formula).

 

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ndI5DsJADAXQq6CpM8n4256tQ6KgT4MU5f7XICMWZQFh0T95+54mRwMGBPAp1KCuczfl4sezz9JnH3oqyc3dhhFMTJKBka0pVdCKRem1McR/2XqFlBpi3SNNPxFe4yO/USgHRGJAEhuKIH8d2Sd+zL6/BKqS0ZnqcQ0wOja6bHObqL4Fv7BiYmxhUtnyuwtrOyhl+Mv4jB57I+WTme8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ReceiveTimestamp = _t, Custom = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ReceiveTimestamp", type datetime}, {"Custom", type text}}),
    #"Extracted Text Before Delimiter" = Table.TransformColumns(#"Changed Type", {{"ReceiveTimestamp", each Text.BeforeDelimiter(Text.From(_, "en-US"), " "), type date}}),
    #"Grouped Rows" = Table.Group(#"Extracted Text Before Delimiter", {"ReceiveTimestamp", "Custom"}, {{"Count", each Table.RowCount(_), Int64.Type}}, GroupKind.Local)
in
    #"Grouped Rows"

 

 

 

 

spinfuzer_0-1704223345065.png

 

Worked Magic!

we didn't have to create a new batch to your point since the Product is there. I'll try applying for all data as well. Thanks much @spinfuzer 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.