Adding Columns for section title in a PDF

DRSteele

Well-known Member
Joined
Mar 31, 2015
Messages
2,654
Office Version
  1. 365
Platform
  1. Windows
Can someone please help me?

I used PQ to import a PDF (this one). I want to create two new columns, one for all the broad section headings (e.g., CANADIAN STOCKS) and another for the all sub-headings (e.g., Broad Market). Like this example I manually manipulated in Excel:

1603399597218.png


How can I do that in PQ?
 
Last edited:
I did all (I hope) for Type column and some for Style column, the rest you need to do yourself
TypeStyleFund NameTicker Symbol
CANADIAN STOCKSBroad MarketiShares Core S&P/TSX Capped Composite Index ETFXIC
CANADIAN STOCKSBroad MarketiShares S&P/TSX 60 Index ETFXIU
CANADIAN STOCKSBroad MarketiShares S&P/TSX Completion Index ETFXMD
CANADIAN STOCKSBroad MarketiShares S&P/TSX SmallCap Index ETFXCS
CANADIAN STOCKSDividendiShares Core MSCI Canadian Quality Dividend Index ETFXDIV
CANADIAN STOCKSDividendiShares S&P/TSX Composite High Dividend Index ETFXEI
CANADIAN STOCKSDividendiShares Canadian Select Dividend Index ETFXDV
CANADIAN STOCKSDividendiShares S&P/TSX Canadian Dividend Aristocrats Index ETFCDZ
CANADIAN STOCKSFactoriShares MSCI Min Vol Canada Index ETFXMV
CANADIAN STOCKSFactoriShares MSCI Multifactor Canada Index ETFXFC
CANADIAN STOCKSFactoriShares Canadian Growth Index ETFXCG
CANADIAN STOCKSFactoriShares Canadian Value Index ETFXCV
CANADIAN STOCKSFactoriShares Canadian Fundamental Index ETFCRQ
CANADIAN STOCKSESGiShares ESG Advanced MSCI Canada Index ETFXCSR
CANADIAN STOCKSESGiShares ESG Aware MSCI Canada Index ETFXESG
CANADIAN STOCKSESGiShares Jantzi Social Index ETFXEN
CANADIAN STOCKSSectorsiShares Equal Weight Banc & Lifeco ETFCEW
CANADIAN STOCKSSectorsiShares S&P/TSX Capped Consumer Staples Index ETFXST
CANADIAN STOCKSSectorsiShares S&P/TSX Capped Energy Index ETFXEG
CANADIAN STOCKSSectorsiShares S&P/TSX Capped Financials Index ETFXFN
CANADIAN STOCKSSectorsiShares S&P/TSX Capped Information Technology Index ETFXIT
CANADIAN STOCKSSectorsiShares S&P/TSX Capped Materials Index ETFXMA
CANADIAN STOCKSSectorsiShares S&P/TSX Capped REIT Index ETFXRE
CANADIAN STOCKSSectorsiShares S&P/TSX Capped Utilities Index ETFXUT
U.S. STOCKSBroad MarketiShares Core S&P U.S. Total Market Index ETFXUU
U.S. STOCKSBroad MarketiShares Core S&P U.S. Total Market Index ETFXUU.U
U.S. STOCKSBroad MarketiShares Core S&P U.S. Total Market Index ETF (CAD-Hedged)XUH
U.S. STOCKSBroad MarketiShares Core S&P 500 Index ETFXUS
U.S. STOCKSBroad MarketiShares Core S&P 500 Index ETFXUS.U
U.S. STOCKSBroad MarketiShares Core S&P 500 Index ETF (CAD-Hedged)XSP
U.S. STOCKSBroad MarketiShares S&P U.S. Mid-Cap Index ETFXMC
U.S. STOCKSBroad MarketiShares S&P U.S. Mid-Cap Index ETFXMC.U
U.S. STOCKSBroad MarketiShares S&P U.S. Mid-Cap Index ETF (CAD-Hedged)XMH
U.S. STOCKSBroad MarketiShares S&P U.S. Small-Cap Index ETFXSMC
U.S. STOCKSBroad MarketiShares S&P U.S. Small-Cap Index ETF (CAD-Hedged)XSMH
U.S. STOCKSBroad MarketiShares NASDAQ 100 Index ETF (CAD-Hedged)XQQ
U.S. STOCKSBroad MarketiShares U.S. Small Cap Index ETF (CAD-Hedged)XSU
U.S. STOCKSDividendiShares Core MSCI US Quality Dividend Index ETFXDU
U.S. STOCKSDividendiShares Core MSCI US Quality Dividend Index ETFXDU.U
U.S. STOCKSDividendiShares Core MSCI US Quality Dividend Index ETF (CAD-Hedged)XDUH
U.S. STOCKSDividendiShares U.S. High Dividend Equity Index ETFXHU
U.S. STOCKSDividendiShares U.S. High Dividend Equity Index ETF (CAD-Hedged)XHD
U.S. STOCKSDividendiShares US Dividend Growers Index ETF (CAD-Hedged)CUD
U.S. STOCKSFactoriShares MSCI Min Vol USA Index ETFXMU
U.S. STOCKSFactoriShares MSCI Min Vol USA Index ETFXMU.U
U.S. STOCKSFactoriShares MSCI Min Vol USA Index ETF (CAD-Hedged)XMS
U.S. STOCKSiShares MSCI USA Momentum Factor Index ETFiShares MSCI USA Momentum Factor Index ETFXMTM
U.S. STOCKSiShares MSCI USA Quality Factor Index ETFiShares MSCI USA Quality Factor Index ETFXQLT
U.S. STOCKSiShares MSCI USA Value Factor Index ETFiShares MSCI USA Value Factor Index ETFXVLU
U.S. STOCKSiShares MSCI USA Value Factor Index ETFiShares MSCI Multifactor USA Index ETFXFS
U.S. STOCKSiShares MSCI USA Value Factor Index ETFiShares MSCI Multifactor USA Index ETFXFS.U
U.S. STOCKSiShares MSCI USA Value Factor Index ETFiShares MSCI Multifactor USA Index ETF (CAD-Hedged)XFA
U.S. STOCKSiShares MSCI USA Value Factor Index ETFiShares US Fundamental Index ETFCLU
U.S. STOCKSiShares MSCI USA Value Factor Index ETFiShares US Fundamental Index ETFCLU.C
U.S. STOCKSESGiShares ESG Advanced MSCI USA Index ETFXUSR
U.S. STOCKSESGiShares ESG Aware MSCI USA Index ETFXSUS
U.S. STOCKSBroad MarketiShares Core MSCI EAFE IMI Index ETFXEF
U.S. STOCKSBroad MarketiShares Core MSCI EAFE IMI Index ETFXEF.U
U.S. STOCKSBroad MarketiShares Core MSCI EAFE IMI Index ETF (CAD-Hedged)XFH
U.S. STOCKSBroad MarketiShares MSCI EAFE Index ETF (CAD-Hedged)XIN
U.S. STOCKSFactoriShares MSCI Min Vol EAFE Index ETFXMI
U.S. STOCKSFactoriShares MSCI Min Vol EAFE Index ETF (CAD-Hedged)XML
U.S. STOCKSFactoriShares MSCI Multifactor EAFE Index ETFXFI
U.S. STOCKSFactoriShares MSCI Multifactor EAFE Index ETF (CAD-Hedged)XFF
U.S. STOCKSFactoriShares International Fundamental Index ETFCIE
U.S. STOCKSFactoriShares MSCI Europe IMI Index ETFXEU
U.S. STOCKSFactoriShares MSCI Europe IMI Index ETF (CAD-Hedged)XEH
U.S. STOCKSFactoriShares Japan Fundamental Index ETF (CAD-Hedged)CJP
U.S. STOCKSESGiShares ESG Advanced MSCI EAFE Index ETFXDSR
U.S. STOCKSESGiShares ESG Aware MSCI EAFE Index ETFXSEA
EMERGING MARKETS STOCKSBroad MarketiShares Core MSCI Emerging Markets IMI Index ETFXEC
EMERGING MARKETS STOCKSBroad MarketiShares Core MSCI Emerging Markets IMI Index ETFXEC.U
EMERGING MARKETS STOCKSBroad MarketiShares MSCI Emerging Markets Index ETFXEM
EMERGING MARKETS STOCKSFactoriShares Emerging Markets Fundamental Index ETFCWO
EMERGING MARKETS STOCKSFactoriShares MSCI Min Vol Emerging Markets Index ETFXMM
EMERGING MARKETS STOCKSESGiShares ESG Aware MSCI Emerging Markets Index ETFXSEM
EMERGING MARKETS STOCKSESGiShares China Index ETFXCH
EMERGING MARKETS STOCKSESGiShares India Index ETFXID
GLOBAL STOCKSBroad MarketiShares Core MSCI All Country World ex Canada Index ETFXAW
GLOBAL STOCKSBroad MarketiShares Core MSCI All Country World ex Canada Index ETFXAW.U
GLOBAL STOCKSBroad MarketiShares MSCI World Index ETFXWD
GLOBAL STOCKSDividendiShares Core MSCI Global Quality Dividend Index ETFXDG
GLOBAL STOCKSDividendiShares Core MSCI Global Quality Dividend Index ETFXDG.U
GLOBAL STOCKSDividendiShares Core MSCI Global Quality Dividend Index ETF (CAD-Hedged)XDGH
GLOBAL STOCKSDividendiShares Global Monthly Dividend Index ETF (CAD-Hedged)CYH
GLOBAL STOCKSFactoriShares MSCI Min Vol Global Index ETFXMW
GLOBAL STOCKSFactoriShares MSCI Min Vol Global Index ETF (CAD-Hedged)XMY
GLOBAL STOCKSSectorsiShares S&P/TSX Global Base Metals Index ETFXBM
GLOBAL STOCKSSectorsiShares S&P/TSX Global Gold Index ETFXGD
GLOBAL STOCKSSectorsiShares Global Water Index ETFCWW
GLOBAL STOCKSSectorsiShares Global Healthcare Index ETF (CAD-Hedged)XHC
GLOBAL STOCKSSectorsiShares S&P Global Consumer Discretionary Index ETF (CAD-Hedged)XCD
GLOBAL STOCKSSectorsiShares S&P Global Industrials Index ETF (CAD-Hedged)XGI
GLOBAL STOCKSSectorsiShares Global Agriculture Index ETFCOW
GLOBAL STOCKSSectorsiShares Global Infrastructure Index ETFCIF
GLOBAL STOCKSSectorsiShares Global Real Estate Index ETFCGR
CANADIAN BONDSBroad MarketiShares Core Canadian Universe Bond Index ETFXBB
CANADIAN BONDSBroad MarketiShares High Quality Canadian Bond Index ETFXQB
CANADIAN BONDSBroad MarketiShares Canadian Government Bond Index ETFXGB
CANADIAN BONDSBroad MarketiShares Canadian Corporate Bond Index ETFXCB
CANADIAN BONDSBroad MarketiShares Canadian HYBrid Corporate Bond Index ETFXHB
CANADIAN BONDSBroad MarketiShares Core Canadian Short Term Bond Index ETFXSB
CANADIAN BONDSBroad MarketiShares Core Canadian Short Term Corporate Bond Index ETFXSH
CANADIAN BONDSBroad MarketiShares Short Term High Quality Canadian Bond Index ETFXSQ
CANADIAN BONDSBroad MarketiShares Core Canadian Long Term Bond Index ETFXLB
CANADIAN BONDSBroad MarketiShares Canadian Real Return Bond Index ETFXRB
CANADIAN BONDSBroad MarketiShares 1-10 Year Laddered Government Bond Index ETFCLG
CANADIAN BONDSBroad MarketiShares 1-5 Year Laddered Government Bond Index ETFCLF
CANADIAN BONDSBroad MarketiShares 1-10 Year Laddered Corporate Bond Index ETFCBH
CANADIAN BONDSBroad MarketiShares 1-5 Year Laddered Corporate Bond Index ETFCBO
CANADIAN BONDSESGiShares ESG Canadian Aggregate Bond Index ETFXSAB
CANADIAN BONDSESGiShares ESG Canadian Short Term Bond Index ETFXSTB
CANADIAN BONDSESGiShares Floating Rate Index ETFXFR
CANADIAN BONDSESGiShares Premium Money Market ETFCMR
CANADIAN BONDSESGiShares Convertible Bond Index ETFCVD
GLOBAL BONDSESGiShares U.S. IG Corporate Bond Index ETF (CAD-Hedged)XIG
GLOBAL BONDSESGiShares Global Government Bond Index ETF (CAD-Hedged)XGGB
GLOBAL BONDSESGiShares J.P. Morgan USD Emerging Markets Bond Index ETF (CAD-Hedged)XEB
GLOBAL BONDSESGiShares U.S. High Yield Fixed Income Index ETF (CAD-Hedged)CHB
GLOBAL BONDSESGiShares U.S. High Yield Bond Index ETF (CAD-Hedged)XHY
GLOBAL BONDSESGiShares Short Duration High Income ETF (CAD-Hedged)CSD
GLOBAL BONDSESGiShares Conservative Short Term Strategic Fixed Income ETFXSC
GLOBAL BONDSESGiShares Conservative Strategic Fixed Income ETFXSE
GLOBAL BONDSESGiShares Short Term Strategic Fixed Income ETFXSI
SPECIALTYESGiShares Gold Bullion ETF (CAD-Hedged)CGL
SPECIALTYESGiShares Gold Bullion ETFCGL.C
SPECIALTYESGiShares Silver Bullion ETF (CAD-Hedged)SVR
SPECIALTYESGiShares Silver Bullion ETFSVR.C
SPECIALTYESGiShares S&P/TSX Canadian Preferred Share Index ETFCPD
SPECIALTYESGiShares S&P/TSX North American Preferred Stock Index ETF (CAD-Hedged)XPF
SPECIALTYESGiShares Core Income Balanced ETF PortfolioXINC
SPECIALTYESGiShares Core Conservative Balanced ETF PortfolioXCNS
SPECIALTYESGiShares Core Balanced ETF PortfolioXBAL
SPECIALTYESGiShares Core Growth ETF PortfolioXGRO
SPECIALTYESGiShares Core Equity ETF PortfolioXEQT
SPECIALTYESGiShares ESG Conservative Balanced ETF PortfolioGCNS
SPECIALTYESGiShares ESG Balanced ETF PortfolioGBAL
SPECIALTYESGiShares ESG Growth ETF PortfolioGGRO
SPECIALTYESGiShares ESG Equity ETF PortfolioGEQT
SPECIALTYESGiShares Diversified Monthly Income ETFXTR
SPECIALTYESGiShares Canadian Financial Monthly Income ETFFIE
 
Upvote 0

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Power Query:
let
    Source = Pdf.Tables(File.Contents("path_to_pdf"), [Implementation="1.1"]),
    Table001 = Source{[Id="Table001"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Table001, [PromoteAllScalars=true]),
    #"Added Conditional Column" = Table.AddColumn(#"Promoted Headers", "Type", each if Text.Contains([Fund Name], "CANADIAN") then [Fund Name] else if Text.Contains([Fund Name], "U.S. STOCKS") then [Fund Name] else if [Fund Name] = "GLOBAL STOCKS" then [Fund Name] else if [Fund Name] = "CANADIAN BONDS" then [Fund Name] else if [Fund Name] = "EMERGING MARKETS STOCKS" then [Fund Name] else if [Fund Name] = "GLOBAL BONDS" then [Fund Name] else if [Fund Name] = "SPECIALTY" then [Fund Name] else null),
    #"Added Conditional Column1" = Table.AddColumn(#"Added Conditional Column", "Style", each if Text.Contains([Fund Name], "Broad Market") then [Fund Name] else if [Fund Name] = "Dividend" then [Fund Name] else if Text.Contains([Fund Name], "Factor") then [Fund Name] else if [Fund Name] = "ESG" then [Fund Name] else if Text.Contains([Fund Name], "Sectors") then [Fund Name] else null),
    #"Reordered Columns" = Table.ReorderColumns(#"Added Conditional Column1",{"Type", "Style", "Fund Name", "Ticker#(lf)Symbol", "Mgmt Fee#(lf)(%)", "Net#(lf)Assets#(lf)($mln)", "YTD (%)", "1#(lf)Month#(lf)(%)", "3#(lf)Month#(lf)(%)", "6#(lf)Month#(lf)(%)", "1 Year#(lf)(%)", "3 Year#(lf)(%)", "5 Year#(lf)(%)", "10 Year#(lf)(%)", "Since#(lf)Inception#(lf)(%)", "Inception Date"}),
    #"Filled Down" = Table.FillDown(#"Reordered Columns",{"Type", "Style"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([#"Ticker#(lf)Symbol"] <> null))
in
    #"Filtered Rows"
 
Upvote 0
Sorry for the late reply - I did not see you'd responded.

That last bit does the trick. Thanks for that.

But I need a general solution. I can't use a solution where the user must search through the data and come up with each new Type and Style. I have other PDFs with scores of pages and dozens of Types and Styles.

I suspect that what I seek is not achievable.
 
Upvote 0
Look for option with parameter, where parameter is a list of your PDFs with full path to them (if you want use all PDFs at once). It will be your source line
also you need to create distinct list from Type and from Style (automatically) then somehow join it to the source, and so on...
this is idea only but imho it's doable
 
Last edited:
Upvote 0
or create list of PDFs and use it in DataValidation List, so it will be one PDF at time

I don't know if there is the same structure of data or each pdf is different from the rest
so user will use DVList and refresh. I think this is not too hard :)
 
Upvote 0
@post#15
see this link
there is 56 logs and I can choose one to display (use) various tables
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,760
Messages
6,174,341
Members
452,555
Latest member
colc007

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top