Power Query: Expand multiple lists within a row at once

I have a json file that I've been fairly successful importing into excel using power query. My issue now is dealing with lists in multiple columns.  I need to figure out how to expand the values of the lists at once so I only add rows once, versus multiple
times.
Example:
Row 1 - Text | List1 {1,1,2,4} | List2 {A,B,B,D} | List3 {W,X,Z,Z}|
Row 2 - Text | List1 {1,1,2,4} | List2 {A,B,B,D} | List3 {W,X,Z,Z}|
Row 3 - Text | List1 {1,1,2,4} | List2 {A,B,B,D} | List3 {W,X,Z,Z}|
When I use Table.ExpandListColumn on the first column (List1), it adds rows to the table. Row1 is expanded into four rows, which is fine but I can only do this one at a time resulting in too many rows being added.  Row 1 is expanded as:
Text | 1 | List2 {A,B,B,D} | List3 {W,X,Z,Z}
Text | 1 | List2 {A,B,B,D} | List3 {W,X,Z,Z}
Text | 2 | List2 {A,B,B,D} | List3 {W,X,Z,Z}
Text | 4 | List2 {A,B,B,D} | List3 {W,X,Z,Z}
If you do this again for the next column (list2), it keeps adding rows.  The above example should only have 12 rows. A single row needs to be expanded to look like:
Text | 1 | A | W
Text | 1 | B | X
Text | 2 | B | Z
Text | 4 | D | Z
Note, the lists will always be equal in size across a starting row but may be of larger or smaller sizes and can be null.

You can account for nulls by testing to see if there is a list in the columns, but it would be cleaner to do this using a custom function e.g.
Create a custom function (query) called TableFromLists, The code would be:
(value1, value2, value3)=>
let
    List1 = if Value.Is(value1, type {list}) then value1
     else {value1},
    List2 = if Value.Is(value2, type {list}) then value2
     else {value2},
    List3 = if Value.Is(value3, type {list}) then value3
     else {value3},
    Table = Table.FromColumns({List1,List2,List3})
in
    Table
In the code, you test to see if each input value is a list. If so, then each identifier (List1...List3) is assigned the corresponding input value (value1...value3). If not, each identifier is assigned the input value converted to a list (by
surrounding the input value in braces).
 Then, in the previous step 2, the formula for the custom column would be:
TableFromLists([List1],[List2],[List3])

Similar Messages

  • SAP Query with multiple list lines

    HI Team,
    Can we create multiple list lines in an SAP Query? If yes, how (pls explain the steps)?
    Example of what I am looking for:  can we have a line for the employee, next for spouse & then the next for child, so on...and then the next employee details.
    Also, there might be fields which will repeat in most of these lines for each employee.
    Ex: EE1 Pernr, PA, PSA, SAL, etc
          Dependant SSN, PA, Address, PSA, etc
          Dependant 2 SSN, PA, PSA, ettc
          EE 2 Pernr, PA, PSA, SAL, etc
    Thanks
    RL

    Hi RL,
    Just using SAP Query I don't think it is possible.
    SAP Query puts each and every DB record on a separate line.
    You need ABAP programming for this.
    Regards,
    Dilek

  • Office 365 Excel Power Query Preview Problem Signing In -- Appears Corrupted, Please Repair

    The image below shows that Excel "thinks" I'm signed in with an organizational account that has Power BI Preview, yet Power Query from Excel doesn't think I'm signed in and says it's corrupted when I try to sign in.  I was trying to use the
    online search to find the odata feed that I have set up for Office 365 Power BI Preview.  So, alternatively, when I go to other data sources and specify the odata feed that is set up properly and available, Microsoft says "access forbidden". 
    Clearly, account credentials aren't being passed correctly.  I have read other posts on this forum and have verified that I have the latest Power Query Preview, that I only use lower case letters to sign in, that IE cache is clear.  I have repaired,
    uninstalled and re-installed Power Query Preview multiple times, with no change in this behavior. 
    Any ideas?
    Neil

    Zarar, yes, tried that, and much more. 
    Even though Power BI is supposed to navigate through firewalls, I believe we are having firewall problems. 
    I need to ask our network people to open up for Microsoft on this one, but there's no good information out there on the sites/IPs required to make Power BI Preview work. 
    In addition, the complexity that comes with using domain credentials, Microsoft Account (live) credentials, and Organizational credentials (O365) on the same computer at various times of the day complicates matters.
    That said, I can take my machine to my home network and get as far as attempting to connect to the odata feed I set up -- except the data source is on a computer with an internal IP and Power Query cannot resolve the local computer name -- i.e. x.x.local. 
    So now, I have two questions:
    1. What IPs need to be unblocked to make Power BI work?
    2. Is there a way to get the odata feed to work when the datasource is on an internal network (the datasource is working and tests okay from Power BI Admin -- but does not resolve the machine name when coming in through Excel via the odata feed from an off-site
    location
    Neil

  • New SP Custom List results in Power Query Error: Expression.Error: The key did not match any rows in the table.

    Hi,
    I'm running into something that seems to be a bug in Power Query. I've got my Power Query tables from SharePoint lists into Excel and Power Pivot data model. (Making sure the SharePoint site is in English and I replace MMD columns with normal columns). 
    But then, when I close down Excel, add another custom list to SharePoint, open the Excel workbook and want to add that new custom list using the same connection (via recent data sources).
    It shows the newly added custom list in the explorer but with an error:
    Nothing I can do to fix this; restarting Excel or PC; nothing. 
    The only way I got around this was by removing all my existing data sources and re-create them.. 
    after that, the same SharePoint custom list WAS read with Power Query without an issue.
    Thanks,
    Jeroen

    Its because of recent updates to Power Query.
    In recent updates internally their is some change in syntax for reading particular table from list (I faced this issue while reading data from Excel file, i.e After applying recent update of Power Query my Queries which were working fine before starting
    throwing same error that yo are facing).
    As solution their is small tweak to be done in existing queries, instead of recreating all queries. If you can provide me your complete old query from Advanced editor then I can point to tweak that need to be done.
    Thanks,
    Sagar K

  • Power Query occassionally connects, seems to load, but returns only 200 rows with 1 error

    I have a Power Query that i have used for few weeks, successfully, but occasionally requires being run a few times to return records.  Just lately it seems to require run more than a few times to make it work. 
    When it doesn't return records , it seems to connects and start retrieving data, but returns only randomly like 100 - 200 rows with 1 error.  The error doesn't have any message. So its hard to troubleshoot from that perspective.
    Query appends two other large and merges in a few others. The data sources are either csv files, Sharepoint Lists and tables in workbook.
    I haven't identified anything in terms of environment or query changes that might cause this.
    When it finally does retrieve all records,  it might be after i have done the following things, but i can't say for certain exactly what did the trick:
    * to run query multiple times
    *maybe simply changing anything in query resolves issue
    * making upstream queries (that are merged or appended into this query)  to Not Load to worksheet or model, eg just have connection
    I'd think this type of error and situation while not common is encountered by others.
    Does this ring a bell for anyone, and if so, can you please shed some light on the reasons and resolutions for this?
    Thanks!

    If you click on "1 error" it should show the editor with a query that will select the rows with errors. This unfortunately might not show all errors for various reasons, but you should try it.
    If that doesn't work, here's an example of how to retrieve error details.
    Suppose the following query:
    = Table.FromRecords({[A="B", B="C" + 1]})
    Notice how we're using the + operator with a string and number. This will result in an error.
    I can create a custom column that uses the 'try' operator over the B column. This returns a record with details which I then expand to retrieve the message.
    let
    Source = Table.FromRecords({[A="B", B="C" + 1]}),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each try [B]),
    #"Expand Custom" = Table.ExpandRecordColumn(#"Added Custom", "Custom", {"HasError", "Error"}, {"Custom.HasError", "Custom.Error"}),
    #"Expand Custom.Error" = Table.ExpandRecordColumn(#"Expand Custom", "Custom.Error", {"Message"}, {"Custom.Error.Message"})
    in
    #"Expand Custom.Error"
    Let me know how this works for you.
    Tristan

  • Query for Multiple Rows as XML

    Ok I've seen this topic in the forums, but have failed to get this to work within my process. Basically I have a process that has a user fill out a form, and upon submittal the form writes it's information to a database (via a data connection within the form that invokes a separate process upon submittal.), once this is done the main process is invoked and it's first step is to query that same database and bring back the data in a lower (now exposed) portion of the form that contains certain fields that track the issue history. The query brings back the xml document and I store it in an xml variable (xml_output). I then take this information and use the Set Value object to assign the returned nodes values to the location fields in the form. This works if the query returns only one row. But once the form is moved beyond the initial Task Assignment, (first user), and query returns more than just one row, the added nodes to not show up on the form, i.e I still just get information about the first row in my form. From what I've read the form should be able to recognize the xpath expression, and bring back all the nodes, by in a sense using instance manager to create an instance for each node on the form. My question is how can I get this to work. Jasmin if your still out there... Help!
    Also We're using Adobe LiveCycle ES 8.0
    created the process using Workbench
    the form was reader enabled and saved as a dynamic PDF.
    Thanks
    Mike

    Ok have done the binding of the schema to the form, and I'm getting the information to flow as it's supposed to.  The problem I'm having now, (I know I'm having a bunch.) is that once I've placed the form into my process, and I use the set value operation to pre-fill information I get the form to flow, but the rest of the information that was previously filled in is blank.  So I have checked the variable and nothing wrong there.  It appears the problem is how I'm using the set value operation.  If I don't use the set value operation, the form retains it's information.  And if I use the set value by trying to set the subform value, the form retains it's information, but no pre-fill.  I'm going to try to be a little more detailed here.  The xml that is returned looks like this:
            0016-03-30
            Mike
            Public Works
            alone in the dark
            Type sleep
            -1
            Council
            FYI
            Important
    Flowed and positioned are actual subforms on the form that have their properties set as their names indicates.  The entire path is /form1/Page1/flowed/positioned .  The way I was able to get the form to flow correctly upon the injection of this xml data, was to bind the subforms in the form in this manner, positioned[*].  Designer didn't place the [*] for me so I had to do this myself.  But once I previewed the document, the form pre-populated and created the necessary number of subforms and placed information into the fields correctly.
    Now on the process side, I have created an xfaform variable that stores the form (bound to xsd.)  information, and another xml variable that stores the query return that looks like the xml listed above (has an xsd associated with it for navigating xpath).  My first operation performs the query (JDBC- Query Multiple Rows as XML) and stores it into the xml variable.  The next step of the process is the Set Value operation which is supposed to inject the xml data retrieved from the query into the form.  Initially I tried the an xpath similar to the following:
    /process_data/object/data/form1/page1/flowed/positioned = /xml_data/flowed/positioned.
    No dice.  On this one the form retains the information filled out by the user (didn't explain this earlier, the form is filled out first, and upon submittal the process starts.), but doesn't pre-populate the bottom part of the form.  Next I tried the following xpath:
    /process_data/object/data/form1/page1/flowed = /xml_data/flowed/positioned.
    This time it retained the form information which was filed in by the user, but the bottom part is becomes hidden!  Didn't understand this.  But I started to kinda think that I had to navigate he xpath in order to correctly inject the xml into the form.  That being said my next attempt was:
    /process_data/object/data/form1/page1 = /xml_data
    My thinking was that if on location, I stop at page1, the xml in the variable will allow it to navigate correctly through the form.  Well it worked, but too well.  The top part of the form is blank, but the bottom portion is pre-populated correctly.  Now I'm stuck.  Not sure how to get the rest of the information in the form.  I thought about creating variables form each of the fields and then re-populating them after the injection of xml, but that didn't seem practical.  I'm almost positive it's something I'm not doing correctly with xpath.  Anyway, thanks for all your help on this.
    Mike

  • Return Code - Query for Multiple Rows as XML

    Hi,
    I'm executing an MSSQL stored procedure through the "Query for Multiple Rows as XML" activity in LiveCycle ES. I do this through a call statement such as this:
    { call MyStoredProc(?) }
    This works great, the stored procedure always returns a record set (with or without records). I use this activity rather than "Call Stored Procedure" because I can transform the record set into XML right away within this activity. Unfortunately any exception arising from invoking this stored procedure cannot be handled within the workflow as this activity does not have an exception handler (lightning bolt). In an attempt to handle at least some exceptions we have decided to use try/catches within the stored procedures and return different error codes. Now the problem I am faced with is that there is no way to retrieve the returned code within any of the SQL activities. We don't want to have to write an execute script for each of these SQL calls. Is there any way to do this? Seems like I'm 95% there.
    Thanks
    Nic

    Thanks for the offer, unfortunately we would need something certified by Adobe.
    Nic

  • Multiple Table.AddColumn command in a single Power Query

    I was using this example in another thread for another question and this issue popped up.
    I have this list in sharepoint.
    When I run this Power Query
    let
    Source = SharePoint.Tables("https://server/test"),
    PQtesting = Source{[Name="PQtesting"]}[Content],
    RemovedColumns = Table.RemoveColumns(PQtesting,{"ContentTypeID", "ContentType", "CreatedById", "ModifiedById", "Owshiddenversion", "Version", "Path", "Attachments"}),
    Custom1 = Table.AddColumn(RemovedColumns, "Options 2", each Text.Combine([Options][Value], ", ")),
    Custom2 = Table.AddColumn(RemovedColumns, "Options 1", each Text.Combine([Options][Value], " and "))
    in
    Custom2
    Only column Custom2 shows up in the output, if I remove custom2 then custom1 shows up.  It appears only one custom column shows up at a time as I can swap them and the custom column on the bottom will always show in the output.  I have found examples
    online of others using multiple custom columns.  Is this a limitation of something I'm doing in my code or of sharepoint, or am I doing something wrong?
    Thanks in advance,
    Eric

    I'm a bit embarrassed on how long I have been trying to figure this out.
    Thank you so much for your help.
    Eric

  • How to expande multiple table row from a single button

    I am trying to create an expanding table that expands multiple rows when a single button is clicked.
    So far I have managed to create a table that expands a single row at a time using -
    click
    this.parent.parent.instanceManager.insertInstance();
    I also tried using the following code from an existing woking file that adds a column when a button is clicked -   
    Table1.HeaderRow._Col3SF.addInstance(0);
    Table1.Row1._Col3SF.addInstance(0);
    Table1.Row2._Col3SF.addInstance(0);
    Table1.Row3._Col3SF.addInstance(0);
    I adapted the code to suite my own file -
    click 
    form1.Sub1.Sub3.Table1.Row1.addInstance(0);
    form1.Sub1.Sub3.Table1.Row2.addInstance(0);
    form1.Sub1.Sub3.Table1.Row3.addInstance(0);
    form1.Sub1.Sub3.Table1.Row4.addInstance(0);
    form1.Sub1.Sub3.Table1.Row5.addInstance(0);
    However I receive the following error -
    click Invalid property get operation; subform doesn't have property 'addInstance'
    Regards Maxwell

    I managed to acheive what I needed to do using LCD's Action Builder.
    The Action builder makes it so easy to create advanced content.
    I selected my button obect for the list, then chose - create add a new instance,
    then chose my table from the list.
    I now have a table with multiple rows that expand when a single button is clicked, fantastic!
    Regards Maxwell

  • Can I use Power Query to Import a table from Excel sheet range which starts not from the top row?

    Hi,
    Being an experienced Excel user before Power BI, I am just starting to explore the M and Power Query capabilities, and need help already (ain't easy to google this use case somehow):
    I need to import the table which sits in the Excel file with header row in the row 17 of Excel sheet, with some metadata header in the preceding rows of the columns A and B.
    01: Report name, Quick Report
    02: Report Date, 1/1/2014
    17: Employee Name, Manager, etc...
    18: John Doe, Matt Beaver, etc.
    Both (a) direct attempt to load as Excel file and (b) the indirect way through [From Folder] and formula in custom column -- both lead to the same error: "[DataFormat.Error] External table is not in the expected format."
    Specifically, I tried to use the [Power Query -> From File -> From Folder] functionality, select an Excel file and add a custom column to access the binary content: [Add Custom Column] with formula "=Excel.Workbook([Content])".
    It looks like Power Query expects a rectangular range with headers full-width followed by a contiguous table range to import anything, and refuses to load if that is not the case...
    QUESTION: Is there any way to load whatever-formatted data from Excel first, and then manipulate the overall imported range (like referring to rows starting from 17th using "Table.SelectRows" etc.) to read the actual data? Reading and using
    the metadata from header would be a bonus, but that comes second... The main issue is to get something from a non-regular Excel file to later work with using M formulae ...
    Thanks!
    SAM

    Finally found the answer to this one in ():
    You Cannot Open a Password-Protected Workbook
     If the Excel workbook is protected by a password, you
      cannot open it for data access, even by supplying the correct password with
      your connection settings, unless the workbook file is already open in the
      Microsoft Excel application. If you try, you receive the following error
      message:
    Could not decrypt file.
    ANSWER: So, will have either weave in the work with temporary unprotected files or requires opening them before updating the data source (although this almost defeats the purpose of automation...)
    ANSWER to ORIGINAL QUESTION: password was preventing Power Query from reading the Excel file. For solution see above.
    Thanks anyway for participation and inspiration, Imke!

  • How to use Power Query to load data from a single source into multiple tables

    Hi all,
    I have a requirement to load my data into three different data models using Power Query. Is that possible?
    My source is a SharePoint survey list, with similar questions like:
    1) Course lecturer - John Doe
    1a) The course was useful (rate 1 to 5)
    1b) The lecturer displayed good knowledge of topic (rate 1 to 5)
    2) Course Lecturer - Mary Brown
    2a) The course was useful (rate 1 to 5)
    2b) The lecturer displayed good knowledge of topic (rate 1 to 5)
    I would like to split the data into separate data models (one for John Doe; another for Mary Brown), so that I can compare the different lecturers. Other than running separate surveys for each of them, I thought of using Power Query to transform the data.
    Is it possible?
    Thanks.
    Regards
    GM

    Yes, this is possible.
    Start with a single query that returns you the data for all lecturers.
    Right-click on the "all lecturers" query in the queries pane, and choose Reference, once for each lecturer. This will create a query for each lecturer.
    Open the query for each lecturer and filter the data so that only that lecturer's results are visible.
    Click "Close & Load To..." for each lecturer's query  to load the data into the data model. This will create a data model table for each lecturer.
    If your question is more about how to transform such a survey list into a table that can be easily filtered, please provide an example of how the list shows up in Power Query.
    Ehren

  • Using drag/drop to build data grid rows from multiple lists ?

    Hi,
    I have implemented some simple drag and drop between grids and lists, including images.
    What I need to do now is quite a bit more complex:
    Create rows in a data grid by dragging and dropping from multiple lists. That is, for a given
    row, column 1 receives data from list A and rows in column 2 - 5 receive data from List B
    I haven't found any examples that do this and my initial hacks haven't been successful.
    If you have any suggestions, they would be most appreciated !!!
    Thanks !  

    This does the trick...
    For my destination grid
    protected function dg_dragDropHandler(e:DragEvent):void
    // Dynamically add columns to the grid by dragging them from the new column list
                    if (e.dragInitiator["id"] == "lNewColumn")
                        e.preventDefault();    // handle this manually
                        var Id:Number;
                        var Name:String;
                        var numCols:int = e.dragInitiator["selectedItems"]["length"] as int;
                        for (var i:int=0; i < numCols; i++)
                            Id = e.dragInitiator["selectedItems"][i]["id"];
                            Name = e.dragInitiator["selectedItems"][i]["Name"];
                            addGridColumn(Id, Name);
    private function addGridColumn( Id:Number, Name:String ):void
                    var dgc:DataGridColumn;
                    var cols:Array = dg.columns;
                // not a duplicate column
                        dgc = new DataGridColumn(Name);
                        dgc.width=150;   
                        dgc.headerWordWrap = true;
                        dgc.itemRenderer=new ClassFactory(MyLovelyItemRenderer);    // unlike mxml, must explicitly cast
                        dgc.width=156;
                        dgc.headerText = Name + "\n Message";
                        dgc.dataField="messageId_" + Id.toString();    // allows split on '_' later to get Id
                        dgc.setStyle("textAlign","center");
                        cols.push(dgc);
                        dg.columns = cols;

  • Power Query website with multiple pages

    Hi There,
    Is there a way to use Power Query to extract data from a website that has multiple pages when the URL does not seem to have a page number parameter?
    See the bottom table (Past events) in this site:
    http://www.sqlsaturday.com/events.aspx
    There are multiple pages, but the link to each page is just something like: javascript:__doPostBack('ctl00$ContentPlaceHolder1$GridView2','Page$2')
    Thanks in advance for your help
    Help Others! Don't forget to mark your thread as answered

    I have in the past delved down in to the AJAX URL syntax for refreshes done that way. It is often actually easier to consume such response formats in Power Query.

  • How to automate/parameterize/loop power query?

    Is it possible to write a single generic powerquery command that'll loop through a list of URLs and load the data to a single table? the webpages in question have the same format & table names, just the data contained within is different. I verified
    this by manually defining a powerquery from web import, importing, changing the url, and hitting refresh
    Is it possible to write a generic powerquery import to pull the data in and have it loop to append the data to a target worksheet?
    I tried macro recording some of the powerquery actions of defining an import but it didn't record anything so im assuming i cant use a vba loop to do this.
    I want to avoid having to manually define each from web import explicitly. There's a few hundred i'd need to do.
    Jakub @ Adelaide, Australia

    Here's a quick walkthrough for how to do something like this. I recommend reading through to the end before trying this, because there will a step later on which you'll actually want to do first to simplify things.
    Let's say I want to get presidential election results for multiple US States from Wikipedia. So to start, I use the "From Web" option inside Power Query and specify an URL of
    http://en.wikipedia.org/wiki/California. This lets me pick between several sections of the web page, and I choose the one called "Presidential elections results" and edit it. The results look good
    in the preview, so I go to the "advanced editing" view that shows me the M query:
    let
        Source = Web.Page(Web.Contents("http://en.wikipedia.org/wiki/California")),
        Data5 = Source{5}[Data],
        ChangedType = Table.TransformColumnTypes(Data5,{{"Year", type number}, {"Republican", type text}, {"Democratic", type text}})
    in
        ChangedType
    The numeric index "5" worries me a little because I suspect that there's not enough regularity in the Wikipedia pages for the US states for the 6th section to always be the one that I want. So I edit the query to index by the section name instead
    and confirm that it still produces the results I want:
    let
        Source = Web.Page(Web.Contents("http://en.wikipedia.org/wiki/California")),
        Data5 = Source{[Caption="Presidential elections results"]}[Data],
        ChangedType = Table.TransformColumnTypes(Data5,{{"Year", type number}, {"Republican", type text}, {"Democratic", type text}})
    in
        ChangedType
    Now I need to turn this into a function that can be applied to multiple pages. The only way to do that is to edit the M query directly, but the transformation is relatively straightforward. Again, I confirm that the output is still what I expected after
    making these changes.
    let
        Election.Results = (state) => let
            Source = Web.Page(Web.Contents("http://en.wikipedia.org/wiki/" & state)),
            Data5 = Source{[Caption="Presidential elections results"]}[Data],
            ChangedType = Table.TransformColumnTypes(Data5,{{"Year", type number}, {"Republican", type text}, {"Democratic", type text}})
        in
            ChangedType
    in
        Election.Results("California")
    Now, I want to apply this function to multiple web pages. These might come from a different Excel sheet or from an external file, but I'm just going to build a table of web pages manually. I'll keep the function around, but won't use it just yet in the overall
    formula. Once more, I confirm that the output is what I expect, which is a single table listing three states.
    let
        Election.Results = (state) => let
            Source = Web.Page(Web.Contents("http://en.wikipedia.org/wiki/" & state)),
            Data5 = Source{[Caption="Presidential elections results"]}[Data],
            ChangedType = Table.TransformColumnTypes(Data5,{{"Year", type number}, {"Republican", type text}, {"Democratic", type text}})
        in
            ChangedType,
        States = Table.FromRows({{"California"}, {"Idaho"}, {"Massachusetts"}}, {"State"})
    in
        States
    Now I can use the "Insert Custom Column" feature of the UI to apply my function to the State column. This looks like "=Election.Results([State])" in the dialog. But when I click OK, something unpleasant happens: I get prompted several
    times for "data privacy" settings for each of the URLs I'm trying to access. This is quite annoying, and we're looking for ways to improve the experience -- perhaps by letting you pick that the privacy settings apply to all of
    http://en.wikipedia.org and not just to the specific URL you're trying to access.
    Meanwhile, you can achieve the same thing manually with a kind of underhanded trick by creating a throwaway query which references
    http://en.wikipedia.org and one other website, and using the "data privacy" prompt from that query to define a privacy rule for the entire domain. Exit the editor and create a new "Blank Query" with
    this single formula: "= Binary.Length(Web.Contents("http://en.wikipedia.org")) + Binary.Length(Web.Contents("http://www.bing.com"))" This will prompt
    you to pick a privacy setting for those two websites (I would suggest that "Public" is the right choice). Once you've done that, you can discard this query; its work is done.
    Now if you go back and repeat the steps for the "elections" query, you'll avoid the privacy prompt.
    At this point, you'll have a table with two columns: one that has the state, and one that has the results as Table values. We want to expand out those values, so we click on the expansion indicator in the column header for Custom and pick all fields. The
    result is a table with four columns: State, Custom.Year, Custom.Republican and Custom.Democratic. The latter three fields can be renamed from either the UI or by editing the M code. In my case, I ended up with a program which looks like this:
    let
        Election.Results = (state) => let
            Source = Web.Page(Web.Contents("http://en.wikipedia.org/wiki/" & state)),
            Data5 = Source{[Caption="Presidential elections results"]}[Data],
            ChangedType = Table.TransformColumnTypes(Data5,{{"Year", type number}, {"Republican", type text}, {"Democratic", type text}})
        in
            ChangedType,
        States = Table.FromRows({{"California"}, {"Idaho"}, {"Massachusetts"}}, {"State"}),
        InsertedCustom = Table.AddColumn(States, "Custom", each Election.Results([State])),
        #"Expand Custom" = Table.ExpandTableColumn(InsertedCustom, "Custom", {"Year", "Republican", "Democratic"}, {"Year", "Republican", "Democratic"})
    in
        #"Expand Custom"
    And the job is done!
    Actually, the hard part might just be getting started. Finding a set of web sites which is consistent enough for a single parsing function to work can be rare. As an example, when I tried to add "Washington_(U.S._state)" to my list of states, I
    discovered that its table was formatted differently than the others. And when I tried to add "New_york_state" to the list of states, I found that its section was named "New York State Presidential Election Results" instead of just "Presidential
    election results". So it's possible that you'll have to do an awful lot of tweaking.
    Nonetheless, this should cover the basic steps and help you get started.

  • Power Query and multi-selection columns

    I have a power query pulling data from a sharepoint list some of the list columns allow multiple selections.
    The power query seems to only be pulling in one value instead of all the selected ones in the columns.
    Thanks,
    Eric

    Hi Eric,
    Just to add a bit more detail to what is going.
    In Power Query, SharePoint List columns with multiple selection choices are represented as nested tables with a single column called "Value". Each row of these nested tables will represent a selected choice for the list item. You can examine this by clicking
    on "Table" under the "Options" column on one of the rows.
    By clicking on the "Expand" icon of a column, you are making use of the Table.ExpandTableColumn function. That function will take each row in the table and do a cross product with the rows of the nested tables of the selected column. This means that each
    row will be duplicated as many times as there rows in the nested columns.
    In this specific case, each item in the SharePoint list will become duplicated as many times as there are selected choices for the item. This can be very useful in some cases, but I think that in your case this is not the operation that you're looking for.
    If you want to simply create a column that combines all the selected choices as a single text value, there's a simpler alternative to Alejandro's solution:
    = Table.AddColumn(RemovedColumns, "Options 2", each Text.Combine([Options][Value], ", "))
    You can simply paste the above as a blank step by clicking on the "Fx" icon next to the formula bar. Here we're creating a new column called "Options 2" that combines the text values in the "Value" column of the nested table of the Options column and separate
    each entry by ", ".
    -Tristan

Maybe you are looking for

  • Tool Tip Text for field values in ALV report

    Hi, How to get the tool tip text for the field values in ALV report. Thanks & Regards, Pallavi.

  • Chart - problem with realize one of the function under CR XI

    Post Author: mrowa CA Forum: Charts and Graphs Hello, I have problem with realize one of the function under CR XI. I would be persuade if any of us would like to help me. 1)    1) From database (basically from one table), I take data to make report.

  • OC4J, fop, and 11g

    I see some post on this though nothing is totally clear. I need to enable PDF printing. I am using the HTTP Server downloaded from Oracle I am going to install the latest version of oc4j since the default looks like 10.1.3.0 instead of 10.3.1.x. Has

  • IMovie iWeb can not open

    When I used Cleanmymac software uninstall Aperture,Fina Cut Pro and Motion,     iphooto ,imovie and iweb can not opan.      1,after i reinstall ilife11,updat,   iphoto can use.but imovie and iweb still can not open.      2. then i restarted, When i t

  • Cannot re-add Printer after Hard Drive became full

    Hi, I hope someone can help us, we have a PowerBook G4 running 10.2.8 which we have been happily printing on our new Epson Stylus Photo R1800 for the past 3 months. A few days ago however, it looks like the Hard Disk became full during a particularly