Power Query, What Am I missing here.

sandy666

Well-known Member
Joined
Oct 24, 2015
Messages
5,861
Could you explain what this code is supposed to do?

Code:
if [#"Segment No."] = 1 then Text.Trim (Text.Start([Application data],35)) else [B][SIZE=3][COLOR="#FF0000"]{[Index]-1}[#"PO Number"][/COLOR][/SIZE][/B]
 

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

rp2019

New Member
Joined
Jul 9, 2019
Messages
11
Could you explain what this code is supposed to do?

Code:
if [#"Segment No."] = 1 then Text.Trim (Text.Start([Application data],35)) else [B][SIZE=3][COLOR=#ff0000]{[Index]-1}[#"PO Number"][/COLOR][/SIZE][/B]
I am looking at the column "Segment_No". if it is 1 then, the PO_Number=Application_data field is trimmed 1-35 , else PO_Number = PO_Number from the previous record
 

sandy666

Well-known Member
Joined
Oct 24, 2015
Messages
5,861
You calling PO Number itself
How should it look like according to you?
 

rp2019

New Member
Joined
Jul 9, 2019
Messages
11
You calling PO Number itself
How should it look like according to you?
numberCounterSegment No.SAP segment nameNo. higher segmentHierarchy levelData Filter Value foLengthApplication dataPO_Number
31370899801E1EDK0901 1000A11517 20190625190625 BA11517
31370899802E1EDKA112 1000LF FTL MFGA11517
31370899803E1EDKA112 1000YSCBW 7A11517
31370899804E1EDK1112 1000YHT1 1 Customer Horizon Start Date: 06/25/19 Customer Horizon End Date: 12/22/19A11517
31370899805E1EDK1112 1000YHT1 2 TMP 92 = 001A11517
31370899806E1EDP1012 1000BW K151860 001 0.000000 20190624 20190625 0.000000 03 534A11517
31370899807E1EDP1663 10004W20190809 20190809 6A11517
31370901801E1EDK0901 1000A11517 20190625190625 BA11517
31370901802E1EDKA112 1000LF FTL MFGA11517
31373401801E1EDK0901 1000A11596 20190625190625 BA11596
31373401801E1EDKA101 1000LF FTL MFGA11596
<colgroup><col width="82" style="width: 62pt; mso-width-source: userset; mso-width-alt: 2998;"> <col width="64" style="width: 48pt;" span="2"> <col width="124" style="width: 93pt; mso-width-source: userset; mso-width-alt: 4534;"> <col width="96" style="width: 72pt; mso-width-source: userset; mso-width-alt: 3510;"> <col width="64" style="width: 48pt;" span="3"> <col width="462" style="width: 347pt; mso-width-source: userset; mso-width-alt: 16896;"> <col width="64" style="width: 48pt;"> <tbody> </tbody>
 

rp2019

New Member
Joined
Jul 9, 2019
Messages
11
IGNORE MY PREV MSG

You calling PO Number itself
How should it look like according to you?
numberCounterSegment No.SAP segment nameNo. higher segmentHierarchy levelData Filter Value foLengthApplication dataPO_Number
31370899801E1EDK0901 1000A11517 20190625190625 BA11517
31370899802E1EDKA112 1000LF FTL MFGA11517
31370899803E1EDKA112 1000YSCBW 7A11517
31370899804E1EDK1112 1000YHT1 1 Customer Horizon Start Date: 06/25/19 Customer Horizon End Date: 12/22/19A11517
31370899805E1EDK1112 1000YHT1 2 TMP 92 = 001A11517
31370899806E1EDP1012 1000BW K151860 001 0.000000 20190624 20190625 0.000000 03 534A11517
31370899807E1EDP1663 10004W20190809 20190809 6A11517
31370901801E1EDK0901 1000A11517 20190625190625 BA11517
31370901802E1EDKA112 1000LF FTL MFGA11517
31373401801E1EDK0901 1000A11596 20190625190625 BA11596
31373401802E1EDKA101 1000LF FTL MFGA11596
<colgroup><col width="64" style="width: 48pt;"> <col width="82" style="width: 62pt; mso-width-source: userset; mso-width-alt: 2998;"> <col width="64" style="width: 48pt;" span="2"> <col width="124" style="width: 93pt; mso-width-source: userset; mso-width-alt: 4534;"> <col width="96" style="width: 72pt; mso-width-source: userset; mso-width-alt: 3510;"> <col width="64" style="width: 48pt;" span="3"> <col width="462" style="width: 347pt; mso-width-source: userset; mso-width-alt: 16896;"> <col width="64" style="width: 48pt;" span="2"> <tbody> </tbody>
 

sandy666

Well-known Member
Joined
Oct 24, 2015
Messages
5,861
ok I understand PO Number now but still I need representative example of source data which reflect structure and data type.
 

sandy666

Well-known Member
Joined
Oct 24, 2015
Messages
5,861
and why you extract 35 characters if you need only 6 ?
 

sandy666

Well-known Member
Joined
Oct 24, 2015
Messages
5,861
sure, my mistake

maybe

Code:
[SIZE=1]// Query1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"IDoc number", Int64.Type}, {"Counter", Int64.Type}, {"Segment No.", Int64.Type}, {"SAP segment name", type text}, {"No. higher segment", Int64.Type}, {"Hierarchy level", Int64.Type}, {"Data Filter Value fo", type any}, {"Length", Int64.Type}, {"Application data", type text}}),
    RC = Table.RemoveColumns(Type,{"Data Filter Value fo", "Hierarchy level", "No. higher segment", "Counter"}), Index = Table.AddIndexColumn(RC, "Index", 0, 1),
    Extract = Table.TransformColumns(Index, {{"Application data", each Text.BeforeDelimiter(_, " "), type text}}),
    PONumber = Table.FillDown(Table.AddColumn(Extract, "PO Number", each if [#"Segment No."] = 1 then Text.Trim (Text.Start([Application data],35)) else null),{"PO Number"})
in
    PONumber[/SIZE]
 

rp2019

New Member
Joined
Jul 9, 2019
Messages
11
and why you extract 35 characters if you need only 6 ?
that is the data that we are getting from outside party and they have 35 characters allocated for it. Does that influence what I am trying to do?
 

Watch MrExcel Video

Forum statistics

Threads
1,102,889
Messages
5,489,551
Members
407,700
Latest member
SimpleJuan

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top