PowerBi Pivot creates repeating values and inserts extra nulls - powerbi

This is probably going to come out with a really simple solution, but I am having trouble with a simple pivot in PowerBI.
I have a table where I have the costs of different utilities in one column, by month. I want to pivot the different utility types into separate columns, so I just have one row of data per month, with the different utility types across the top.
A simple pivot for some reason puts a bunch of nulls in and repeats the Months column, and I am not sure where I am going wrong.
Original Table
Final Table with Problem

My eyes glossed over that first column, not realizing the unique IDs in that column were causing the problem. I got rid of EngieTable_ID and my table works now.

Related

Join 2 table in power bi

I need help on this issue as i don't have any experience in Power Bi. I want to join 2 table in Power Bi where it have the same column which is Part_Number. How can i make this 2 table to match by Part Number and return the value?
Recon Table
Inventory Table
I would like to have Part Number, Part Name, QTY, Total Quantity as the result. Hope that i can the clarification i need. Thanks a lot!
For this case you simply must merge the tables. It doesn't look like you have done a lot of research on the matter though, so it's hard to understand exactly what you need help with.
To merge your two tables in Power Query, I would right click in the left hand side menu and select Merge Queries as New.
After that you simply follow the on-screen instructions and select your two tables and their respective key columns. After merging you can choose to disable load of your two original tables to save space in your data model, but this depends on your requirements.
If this was my data model, I would think on why joining these tables are necessary, instead of using these two tables as fact tables, and creating a third table to handle the part number dimension with associated part metadata.
Read the docs: Merge queries in Power Query

Creating a new table with data from tables of varying size

Hi I have two tables one has a large number of orders with a column for date. The second table has one column labeled month and another with hours making for 12 rows in total. I want to make a new column by dividing the count of orders per month by the hours of that month from the second table.
In excel i'd simply countif orders that are in January from the first table and divide by the hours in January from the second.
I'm having trouble figuring out the best way to make this new table with calculated values from the existing tables.
Thanks for your time.
Below is a picture of table 2. The first table is a standard dataframe with thousands of rows.
Two options.
You can use the "Append Query" and create a new table that is combining all of your data.
You can also use CALCULATE(SUM(table[field]), filter(table, table[field] = table[monthfield]) /SUM(table[field])
If you could give an example of what you have, I could definitely show you how to accomplish this.
Here is a link to the solution file. One by merging data, and one by using CALCULATE(SUM(),FILTER())
https://drive.google.com/file/d/1yxpv62Dnv8LSNW_mxibPfL0aCMrepoCU/view?usp=sharing

Power BI / Power Query - M language - playing with data inside group table

Hello M language masters!
I have a question about working with grouped rows when the Power Query creates a table with data. But maybe it is better to start from the beginning.
Important information! I will be asking for example only about adding an index. I know that there are different possibilities to reach such a result. But for this question, I need an answer about the possibility to work on tables. I want to use this answer in different actions (e.g table sorting, adding columns in group table).
In my sample data source, I have a list of fake transactions. I want to add an index for each Salesman, to count operations for each of them.
Sample Data
So I just added this file as a data source in Power BI. In Power query, I have grouped rows according to name. This step created form me column contained a table for each Salesman, which stores all his or her operations.
Grouping result
And now, I want to add an index column in each table. I know, that this is possible by adding a new column to the main table, which will be store a new table with added index:
Custom column function
And in each table, I have Indexed. That is good. But I have an extra column now (one with the table without index, and one with a table with index).
Result - a little bit messy
So I want to ask if there is any possibility to add such an index directly to the table in column Operations, without creating the additional column. My approach seems to be a bit messy and I want to find something cleaner. Does anyone know a smart solution for that?
Thank you in advance.
Artur
Sure, you may do it inside Table.Group function:
= Table.Group(Source, {"Salesman"}, {"Operations", each Table.AddIndexColumn(_, "i", 1, 1)})
P.S. To add existing index column to nested table use this code:
= Table.ReplaceValue(PreviousStep,each [index],0,(a,b,c)=>Table.AddColumn(a,"index", each b),{"Operations"})

Grouping by multiple columns and aggregating all values

I am rather new to Power Bi and I have a question i can't find the answer to.
I want to import a table that have some label columns, with repeated items, and more than 15 data columns.
My desire result would be to group the label columns, so no repeated items, and aggregate the values of the remaining columns.
Is there a way to do that in PQ editor or DAX ?
I appreciate any help or direction you can give me!
A sample of the table (it's much bigger, with multiple values in the first three columns)
Table Sample
Thanks a lot
Edit: From that sample, the output y I want is the following
Output Sample
The thing is, there are many different values in the first columns, and i need to agreggate all the other values, keeping they column name (cause this info is already linked to other files).
Maybe the only way is to group by and add the columns, renaming them one by one?
I want to do this in a couple of files, so if you know of another way please let me know!
In your query designer import your table. Then go to Home > Group By and group like you want it, the same goes for the aggregations and thats it.
If you just want to remove row duplicates, just group all columns which you dont want to aggregate and the rest can be aggregated like you want it.

Why doesn't ALL function ignore filter when data is sliced by columns in pivot table?

I'm new to the DAX world and I just faced a conceptual misunderstanding.
While I was trying to debug a measure, I found a unexpected (for me) behaviour with the ALL function. I wrote a simple measure COUNTROWS(ALL(Table)) but to my surprise, when I sliced the data by a column, the same number did not appear in each cell in the values field, ignoring the filter context in the way I was expecting:
So, what am I missing?
Since there are no BUYs on e.g. 01/08/2017, it's not even evaluating the measure. Since that cell doesn't correspond to any rows in the original table, it's not doing any computations.
If you had a BUY and a SELL on the same day, it should show up in both columns on that day.