Forum Discussion
How to reference Text in a Cell to create a new column
- 5 years ago
Hi Anonymous
SheetCellA4 =YourWorkSheet[Column1]{3}Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
- 5 years ago
Hello Anonymous
you are using an approach of accessing a xlsx-file even you are accessing a csv-file. In your case the Source-step will give you already the final table. So use this code instead
let Source = Csv.Document(File.Contents("C:\Users\cday\OneDrive - udfinc.com\M6 Scorecard\Data Pulls\4 Wk Data.csv"),[Delimiter=",", Columns=18, Encoding=1252, QuoteStyle=QuoteStyle.None]), #"Added Custom" = Table.AddColumn(Source, "Custom", each Query1(Source)) in #"Added Custom"If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Anonymous
The file downloaded from that link is xlsx, not csv?? I do not know if it was xlsx from the beginning or if it is converted to xlsx when I download. Anyway with that xlsx file, you can do the following.
1. Change slightly the function. Just remove the last step since it deletes the last character of the string and that doesn't seem to be what you want:
= (YourWorkSheet as table ) as text=>
let
SheetCellA4 =YourWorkSheet[Column1]{3},
SplitByFrom = Text.Split(SheetCellA4, "'From: "){1},
SplitByTime = Text.Split(SplitByFrom, "`"){0}
in
SplitByTime
2. Create another query for the main processing:
let
Source = Excel.Workbook(File.Contents("C:\Users\cday\OneDrive - udfinc.com\M6 Scorecard\Data Pulls\4 Wk Data.xlsx"), null, true),
in_Sheet = Source{[Item="in",Kind="Sheet"]}[Data],
valueOfInterest_ = Query1(in_Sheet),
#"Removed Top Rows" = Table.Skip(in_Sheet,16),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),
#"Added Custom" = Table.AddColumn(#"Promoted Headers", "Adde column", each valueOfInterest_)
in
#"Added Custom"
You'll have to review if you want all those columns, since some of them are all nulls. If you want me to have a look at the csv, you need to make sure I can download the csv
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
I updated my original post with the link, and final outcome.
I'm not sure why the extension is showing as xlsx. I just double checked, and it's saved as .csv
I do want to eliminate the last character of the sting ( ` ).
The blank rows were because I needed to delete confidential data, but I do need them.
I copied your code, the only thing I changed was the extension to ".csv".
let
Source = Excel.Workbook(File.Contents("C:\Users\cday\OneDrive - udfinc.com\M6 Scorecard\Data Pulls\4 Wk Data.csv"), null, true),
in_Sheet = Source{[Item="in",Kind="Sheet"]}[Data],
valueOfInterest_ = Query1(in_Sheet),
#"Removed Top Rows" = Table.Skip(in_Sheet,16),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),
#"Added Custom" = Table.AddColumn(#"Promoted Headers", "Adde column", each valueOfInterest_)
in
#"Added Custom"
But I received this error: