Hi @Cedo Vranjes
If Excel formula =IF(C2<>C3;1;0) does what you want, the proposal I made earlier does the same thing, more efficiently... So, please do the following to check it:
1/ Copy the sample.pdf file you upload in a folder, let's assume it's C:\MyFolder
2/ In Power BI create a new blank query (Get data > Blank query)
3/ Using the Advanced Editor > Select all > Paste the following query code. Don't hit Done now...
4/ In the Source step replace "**C:\Users\Lz\Downloads**" with **C:\MyFolder**
5/ Click Done (bottom right)
Now check column [LastR] values
QUERY CODE:
let
Source = Pdf.Tables(File.Contents("C:\Users\Lz\Downloads\sample.pdf"), [Implementation="1.1"]),
PromotedHeaders = Table.TransformColumns(Source,
{"Data", each Table.PromoteHeaders(_, [PromoteAllScalars=true]), type table}
),
CombinedTables = Table.Combine(PromotedHeaders[Data]),
ChangedTypes = Table.TransformColumnTypes(CombinedTables,
{
{"Date", type date}, {"Station", type text}, {"NbrAct", Int64.Type}, {"TimeEnd", type time},
{"ActType", type text}, {"Shift", type text}, {"Error", type text}, {"2ndTest", Int64.Type},
{"retest", Int64.Type}, {"LastRes", Int64.Type}, {"1stPos", type number}, {"PADD", type text},
{"TEST1", type text}, {"TrqTS1", Int64.Type}, {"DegTS1", type number}, {"TEST2", type text},
{"STALL2", type text}, {"TrqTS2", Int64.Type}, {"DelPos", type text}, {"Noise", type text},
{"Column21", type text}, {"DIAGA", type text}, {"LaserStr", type datetime}, {"TestTime", Int64.Type},
{"CycleTime", Int64.Type}, {"MaxDurTL", Int64.Type}, {"LateCycsTL", Int64.Type},
{"TotCycsTL", Int64.Type}, {"Time", type text}
}
),
#"Grouped ActNbr" = Table.Group(ChangedTypes, {"NbrAct"},
{"GRP_ActNbr", each
if Table.RowCount() = 1
then Table.AddColumn(, "LastR", each 1, Int64.Type)
else Table.Combine(
{
Table.AddColumn(Table.FirstN(, Table.RowCount()-1), "LastR", each 0, Int64.Type),
Table.AddColumn(Table.LastN(_, 1), "LastR", each 1, Int64.Type)
}
),
type table
}
),
#"Combined ActNbr Tables" = Table.Combine(#"Grouped ActNbr"[GRP_ActNbr])
in
#"Combined ActNbr Tables"
In the below picture [LastR] in bBlue contains the values from the above query, the Orange column use the Excel formula you posted:
