Power Query - How to decode values using two tables? - powerbi

How can we decode a master table like this
to decode values from codes table
to get the result like this in Power query/Power BI?

split the code table into two as Gender code and race code, and relate them to master table.

You will need to do a relationship between the master table and the coded table. But your coded table has 2 different types of data in it, gender and race. To create many to one relationships between the master table and the coded table, you probably have to split the coded table into two tables - gender and race.
Setup the relationships:
Use DAX to create new columns in the master table:
If you cannot split the coded table, then you will need to import it twice, concatenate "gender"/"race" with the code, create the relationships between master and coded 1 and coded 2 and use DAX to create the columns in master.

Related

How do I get a derived table from a matrix in PowerBI?

Hi I am very new to PowerBI and come from Looker. In Looker there is the concept of derived tables which allow you to join the results of a query to the model for additional analysis (similar to a CTE in SQL).
For example, let's say I have a matrix that gets the number of transactions from the table 1 aggregated by the index group name from table 2. How could I join this back onto table 2?
I can export to csv and load into the data model although this is limited to 30k rows.
Please let me know what is best practice here?
How can I save the results from a matrix visualization as a table to the model for additional analysis in PowerBI

Filtering plots in power BI on through column names

I have the following tables
I have several tables on coal consumption, natural gas, .....
I want to have a power BI model that can allow viewing these data with years (x-axis) while filtering on countries.
I have transposed the data to have a column with years and countries on the columns. But I cannot filter on countries.
Another thing I have done is to unpivot all the data and have four columns (country, year, value, fuel type) but the problem is that I could not manage to create suitable relationships between the tables as there is no primary key.
I have thought on putting all the data fro the different energy sources in one table. But how can I manage to link it to more data per country at year as well.
Another thing I have done is to unpivot all the data and have four columns (country, year, value, fuel type)
This is totally the right approach.
The next step required in minimum is to combine all unpivotted tables vertically into one EnergyConsumption table. You can utilize Append Queries command in Power Query Editor, or Table.Combine function in M language.
Additionally, you should consider to create three tables: Years, Countries, and FuelTypes, which have unique values of the respective dimensions, and establish one to many relationship with EnergyConsumption table.

How to create a Fact table from multiple different tables in Pentaho

I have been following a tutorial on creating a data warehouse using Pentaho Data Integration/Kettle.
The tutorial is based off of a CSV file but I am practicing with the northwinds database and postgresql I am trying to figure out how to select values from more than one table then output them into a single table.
My ETL process goes like this: I have several stages for each table, values are selected from each table and stored in a stage table for each table in the database, from there I have my dimensions table set up but I am trying to figure out the step between the stages and the dimensions which is where I am trying to select the values to update the dimensions table.
I have several stages set up for each of my tables at this point I am not sure if I should create a separate values table for each table or a single values table. Any help would be greatly appreciated. Thanks
When I try to select values from multiple tables I get an error that says "we detected rows with varying number of fields" It' seems I would need to create separate tables with
In kette, the metadata structure of the data stream cannot change. As such, if row 1 has 3 columns, one integer and two strings, for example, all rows must have the same structure.
If you're combining rows coming from different sources, you must ensure the structure is the same. That error is telling you that some of the incoming streams of data have a different number of fields.

Join two tables on Power BI using same key in Table A

I'm attempting to create multiple joins with two tables (Table A + Table B) using the same key from Table A. The key on table A is "Name" and there are multiple columns in Table B that I need to join this with. Any ideas on the best way to do this?
Just go ahead and do it. Power BI allows multiple relations between tables, but only one of them will be "active":
Multiple Relationships Between Tables
To use inactive relations, you will have to refer to them in DAX using function called
USERELATIONSHIP
Alternatively, you can replicate your table A as many times as you need, and setup regular relations. In my opinion, it's a better data model - it's more intuitive and easier to use.

power bi: combine multiple tables into one

In Power BI, I am creating a report with some finance data of a company. I have 3 different tables. The table structure of all three tables are as follows:
I want to change these tables into this structure:
Is it possible to achieve this kind of structure? If yes and please suggest some method to do this?
To do it simply you can import 3 times your table using the query editor, and then in one table keep only columns for Planned, in the second table keep columns for Actual, and so on...
Hope that helps!