Power Query: how can I make power query tolerate columns with the same name? - excel

I have a table with several column having the same name.
This columns is updated and provided regularly to power bi.
The columns has several columns with the same name such as "Result", "Result" and do so on...
However, Power BI adds each time in an automated way a number after my columns.
When I try to "force" power bi not to have a number, I get the following message
"The name "Result" is already used for a column..."
How could I change this?
The only way would be for the people using my file to extract the data and correct the name manually in excel...which is not great

You cannot edit this behavior, PowerBI needs an unique identifier to reference the data, therefore the column name must be unique within a table (the complete identifier is given by table + column), otherwise the tool won't be able to reference the data.
This rule usually applies to any tool that manages data and sometimes to the data themselves (that's up to the format though). How can the tool get data from "Result" if more than one column has this identifier? which is the right one? The tool does not know and based on the context can give you an error or will fix this issue itself by making the names unique.
Note that also excel will append numbers to the columns (with the same name names) if you put the data in a proper table (insert-> table), in fact, an excel sheet can be considered unstructured free data, meanwhile, an excel table will enforce the data structure.
Most tools (like PowerBI) will also enforce data types.

Related

How to transform multiple tables in one excel sheet to one table with Power BI?

I would like to transfer this humanly readable table either into one long table, for example through an "Attribute" Column which then includes "Category A" and "Category B" or I would like to split them into multiple sheets within PowerBI. The "delimiter" is always a empty column.
If I guess correct-
You have single spread sheet with data belongs to multiple category.
You wants to load whole data to Power BI
But you need separate sheet per category.
You can perform these following steps to achieve your required data sets in Power BI-
load the sheet to power bi
duplicate your data set as many time you wants number of data set
Go through all data sets and remove all columns except columns you required in current data set.
This should give you your desired data sets in power bi.

Incorrect data being pulled from a SharePoint list to Power BI

When I pull data from a SharePoint list into Power BI, the values are pulled incorrectly for columns having the data type -
Person or Group - instead of names, numerical values are pulled. I guess these are the IDs of the values
Lookup - instead of the actual values, '[list]' is pulled in a nested column. When I expand, numerical values are shown. Again, seems like IDs
All other data types are pulled properly.
To work around this problem, I first pull the data from the list to Excel and then to PBI. However, I want to eliminate this manual step as the list will have frequent updates and I will need to pull the list data into Power BI regularly.
What should be done to pull the actual values as they appear in the list?
For the lookup columns: You need to pull in the lists where the lookup values are being looked up from and then create a relationship based on ID.
For the People: Look here:fully explained how to deal with Person object
I did some looking around and was able to find a solution.
Using the FieldValuesAsText column in the Query Editor, I got the values in the table. values for both column types were available. Since, I only needed the text values it solved the purpose.

Creating an Excel formula to return a specific non-blank mapped value from another row

I am working with a large mapping table in excel. The output of the mapping table is difficult to use when performing analysis and for creating custom files for users.
The Data table is formatted as such:
I would like the New Account Lookup column to always return the mapped system account, as some of the mapped system account output rows from the mapping table are blank due to the system design. The location of the new system account data can be varied in terms of the row number.
Have tried index match and a few complicated if statement variants to no avail. Any help would be appreciated.
I was able to figure this out using the following as an array formula: INDEX(C:C,MATCH(1,(A1=A:A)*(C:C<>""),0))

Access query returns a different result when read from Excel

I have a query in an ACCDB that works fine in Access.
I can successfully copy/paste its data to Excel.
However, from Excel, if I try to insert a Pivot Table using External Data Source, pointing to the very same query, then some numeric fields have weird formatting and some calculated numeric columns (formula in the query) have their value divided by 100 compared to the source.
Never seen that behaviour. Any suggestion ?
The whole MS-Office setup is in 2010.
What I have already done in the source query (without visible improvement):
used CCur() to make sure the figures are in a coherent data type
set the Format property of those culprit columns to "Standard"
The behaviour is exactly the same on other PCs in the same bank.
I could solve the problem which was due to 2 different bugs, probably in JetOLEDB.
Like is not handled properly by Excel
The query contained some formulae using Like:
iif(someField Like "XX*";0;anotherField).
Changing this to iif(Left(somefield;2) = "XX";0;anotherField) solved calculation differences between Excel but and Access.
Reference to another calculated column is handled differently
Say you have 2 query columns:
Rate: i.Rate *100 (i is a table alias)
Amount: Rate*Price
Access calculates Amount using the Rate calculated column, while Excel uses the Rate field from table i.Therefore I had to change the Amount expression to:
Rate: i.Rate *100
Amount: i.Rate *100*Price
since Excel does not seem to make always use Rate from the table (i.Rate).
Use the query in Access to first Make Table in Access then import the table to excel.

How do I create report-like data tables in Excel?

In the past I have created websites that extract data from a database and format it using tables.
Now, I am trying to do the same thing but with Excel, and I'm lost. I am used to using SQL commands to extract data from given fields and then sort/manipulate it.
Currently, I am able to print a report that provides me with an Excel spreadsheet full of raw data, but I would like to make my life easier and organize it into a report.
The column that I would like to reference contains duplicates, but the data in the adjacent columns is different.
To give an example, assume I had a spreadsheet of sales transactions. One column would be the Customer ID, and the adjacent columns would contain the quantity, the cost per unit, total cost, order ID, etc.
What I would want to do in this case would be to select all the transactions with the same Customer ID and add them together based on their Order ID. Then, I would want to print the result to a second sheet.
I realize that I can use built-in functions to accomplish this, but I would also like to format this report evenually using VBA. Also, since I will have a variable number of rows that differ from one report to the next, I haven't encountered a fucnction that will allow you to add rows.
I'm assuming this must be done with VBA.
Well you can do it manually, but it would take ages. So VBA would be good, particularly as you would be able to generate future reports quickly.
My interpretation of what your saying is that each row in your report will be the total for one customer ID. If it's something else, I imagine the below will still be mostly relevant.
I think it would be a bit much to give you the full answer, particularly as you haven't provided full detail but to take a stab at what you'd do:
Create your empty report page, whether it be a new worksheet or a new workbook
Loop through the table (probably using While next is not empty)
a. Identifying if a row is for a customer ID you haven't covered yet
i. If so then add a new entry in your report
ii. Else add it to the existing customer ID record (loop through until you find it)
Format your report so it looks pretty, e.g:
a. Fill the background in white
b. Throw in some filled bars
c. Put in good titles and totals etc.
For part 1, it might be better building an array first and then dumping the contents into the report. It depends how process intensive it will be - if very intense, an array should shave off time.

Resources