How to create a new table from Query data and change rows to column in Power BI - powerbi-desktop

I am new to Power BI. I have searched a solution, but I can't find the one match my issue.
I use direct query to SQL Server to generate data table in Power BI. My query result as below:
And I want to create a new table and transform the data to be as below:
Really appreciate any help or idea.
Thanks

You need to pivot the Factory column to get the desired result.
In Power BI Desktop designer, click Transform data button from the Home ribbon tab to open Power Query Editor. First, delete the Comment column (or don't select it at first place) by right clicking on it's title and select Remove. You don't need it. Then select Factory column and click Pivot Column button from Transform tab:
and select Volume for values column:
This will pivot the column, i.e. make a separate column for each of the values in it, and give you the desired result:
In addition (you said you are using a DQ to get the data), you can also do the same transformation in the database query too.

Related

Refresh powerBI data with additional column

I have built a powerBI dashboard with data source from Datalake Gen2. I am trying to add new column into my original data source. How to refresh from PowerBI side without much issues or whats the best way to do?
You can add the column in your new data source, when Power BI refreshes against the data set you will NOT see it in report designer. You will have to go into the Query editor, select the dataset & refresh the preview. It will then pick up the new column. It will now show in the report designer.
Hope that helps
You can configure the query so that the number of columns is dynamic by setting Columns=null.
These instructions get you to the same place as #Janzaib's answer, but are more intuitive for me.
In Power BI Desktop, right-click on your dataset under Fields ('VoterList' in this case), and select Edit query:
In Power Query Editor, select Advanced Editor:
In Advanced Editor, increment the Columns value:
Note: If you increment this value larger than your data set, you will end up with empty columns.
However, if you set Columns=null, then it will import all of the columns found in your source automatically, even as your source changes.
When you refresh you table and your data has new columns into it. Yes, it will give you issues. Or your new columns will just not show up.
Here is how you can fix it.
Go to Transform Data and select transform data option
Look for "Transform Sample File" on left hand side and select it
Select advanced editor on top center and you should see something like this.
and simply increase the number of columns your sample file can possibly contain.

Cannot find the connection created in power query in pivot table connection

I created a connection appending two tables from power query. Now, I want to update my existing pivot table with the connection. But, I cannot find the option in the "Change data source". But, if I check it in the connections options in the data tab, then, I can see the connection I created. Please help!!!
If the Pivot table is based on the Data Model, then the "Change Data Source" button will be greyed out, because the data source for the Pivot table is the Data Model.
If you have appended two queries, it may well be that all you need to do is refresh the pivot table.
In the following scenario, the first screenshot shows the pivot table when only the table on the left has been loaded to the data model.
In the next picture, the table on the right has been added as a query and saved as a connection. Then the table has been appended with the existing "myQuery". Then the Pivot table has been refreshed and the numbers show that it includes the new data values.
If you want to change the data source for the pivot table when it is sourced from the Data Model, you need to work in the PivotTable Fields panel and select the table or query that you want to use. In the screenshot below, you can see that the pivot table uses fields from myQuery, but I could also select fields from Table1 and Table2, which are the original tables in the grid.

Use datamodel data for cell formula

I have an excel file that has a table imported from a txt in a sheet (using New Query). From that table I created a pivot table and some formulas like for example MAX().
I was told that for large files it is better to add the info to the data model as connection only (the data is not visible in a sheet).
No problem in creating the pivot and works great, but trying to do the formulas excel does not find the Table.
Before I could do something like this:
=+MAX(Table1[#[Column1]])
but know when I do MAX, the system does not find the Table1 I have loaded as connection only. Is there any way to relate a formula to data that has been added to the model as connection only?
Thanks.
In order to access data in the data model you can use "Cube functions" you can follow these steps:
1- From inside the "Manage Data Model" option, create a pivot table of your table
2- Customize the new pivot table according to your needs
3- Click the ribbon "PivotTable Tools" | "Analyze" | "OLAP Tools" | "Covert to formulas"
4- Optional: Merge the formulas in one
Remarks:
The functions (MAX, SUM, Etc.) must be defined in the Pivot Table.
Here is an screencast I created for you.
Reference: https://support.office.com/en-us/article/cube-functions-reference-2378132b-d3f2-4af1-896d-48a9ee840eb2
First Create a Data Model table then use
=MAXIF(Table1[Values],Table1[Labels],"a")

How to link table row content to source in Power View

I am currently able to use Power View to view, filter, and highlight my data. However I haven't figured out a way to link my table rows to the data source (i.e. tables in other tabs of the Excel spreadsheet).
so that if I double-click on a row, Excel will direct me to the appropriate table and show me the full content of that row (so that I can see data in the other columns that I wasn't showing in the Power View dashboard).
For example, I wouldn't put a "Description" column into the dashboard but I would want the user to be able to find and see the paragraph-long description for each item if he or she chooses to drill down.
See image
I want to be able to click on any of those five line items and go to that table with that table filtered for only that item.
Does any one know how to do this?
This is not something that's supported in Power View.
HTH,
-Lukasz

How do you copy the powerpivot data into the excel workbook as a table?

I have data in powerpivot that I've modified and I'd like to place it into the workbook as a regular table (and not as a pivottable). I need this so that I can run use the table for some vlookups from another worksheet in the same workbook.
I found this answer: link which I will try and summarize with out cutting and pasting to much. This assumes you have powerpivot installed.
goto powerpivot and "import from and external source" the data you want to munge and bring back into the workbook as a table
Key here is to select the checkbox “Enable selection of multiple tables”.
when prompted at the "import data" window, pick pivot report (you won't really use this)
go back to powerpivot with the "Manage Data Model:
add a new measure below your data. something like: NRofOrders:=COUNTROWS(values(FactResellerSales[SalesOrderNumber]))+0
(you won't really use this but this seems to change the query to this table so that you can use DAX)
also add any columns that you want ( for me, this is want I wanted that I wanted to be reflected back in the workbook)
back to Excel, select the data tab, click on Existing connections and select Tables: and then pick a table from your query.
boom, you're done
(the link continues on and you should read that as it's interesting but at this point you should have powerpivot query with your modification as a table in your workbook)
The July 2014 update to Power Query (pushed out at the end of Aug) simplifies the answer. With the new Power Query Update you can pull the data into the Data Model with out having to also copy it to the Works sheet.
goto powerquery and import the data you want to munge. Use the option to just add it to the Data Model.
go back to excel and then go to powerpivot with the "Manage Data Model" button.
munge your data (add columns, whatever)
back to Excel, select the data tab, click on Existing connections and select Tables: and then pick a table from your query.
boom, you're done
In the PowerPivot window you can select the table, or elements of it, and then copy (nornal right click or ctrl +c) and paste that into your spreadsheet.
This works for reasonable amounts of data but if you try and do it with thousands of rows you may find that excel objects and falls over, based on my experience.
Vlookups kind of defeat the purpose of PowerPivot :-)
Found a great solution over on Mr Excel
(http://www.mrexcel.com/forum/power-bi/637919-extracting-static-data-powerpivot-without-pivot-tables.html)
If you are trying to get a PowerPivot table into Excel, then you can simply query it. The easiest way to set that up is to first create any pivot table based on you PowerPivot data. Then double-click the measures area to drill-through. This creates a table with a connection to your PowerPivot model. Then edit the command text by going to: Data > Connections > Properties > Definition tab > Command Text.
Change it to something like
Code:
EVALUATE Table1

Resources