How to create Power BI datamodel - powerbi

I have 3 tables:
A: Columns (a,b,c,d)
B: Columns (a,c,f)
C: Columns (f,c,h,k)
I could able to create a merge column between a+c , f+C and join tables. Purpose is to get count of A(b) by A(d) and C(k).
Visual shows counts by A(d) fine but drill down into C(k) shows same counts on all bars. what is the mistake? Is it in joins? Model shows relation as 1:1 between these tables. Table B and C are related, Tables A and B are related but table A has no direct relation with table C, is this the issue?
Please enlighten.
enter image description here

Related

PowerBI filter one table with multiple columns from another table

Here I have two tables:
Table A: col_A, col_B, col_C, metric_1, metric_2, metric_3
Table B: col_A, col_B, col_C, metric_X, metric_Y, metric_Z
I may need to put them in the report with col_A, col_B, col_C as shared filters. col_A, col_B, col_C are many to many relationship, for example, age, country, domain. How could I achieve this?
The solutions I may know are:
Pull column col_A, col_B, col_C as filters from table 1, but in this case table 2 doesn't have any relation with table 1 and the filter won't work for table 2. And if I add relation of table 2 with table 1 for col_A, then I couldn't next also add relation for col_B or col_C as only one relation could be added.
Another solution is that I would extract col_A, col_B, col_C as a new table for dimensions shared between table 1 and table 2. Then the filters may have better performance as there is less data. However, how could I apply the shared dimension table filter to table 1 and table 2? Or is there way like filter could achieve this?
ForAll(Table1, Collect(col_A, Filter(Table2, col_A in FullName).FullName))
Thanks.
In my opinion, you have two main choices here:
Calculate common dimension tables separately for each Col_A, Col_B, Col_C
Create a common key in each Table A, Table B and create one common dimension table
Common dimension tables for each column
For my simplified model of just two common columns, I have created one separate table per dimension:
The code to create Dim_A is just to use DISTINCT and UNION to get all the possible values from both tables:
Dim_A =
DISTINCT (
UNION (
DISTINCT ( 'Table A'[Col_A] ) ,
DISTINCT ('Table B'[Col_A] )
)
)
It is common to hide the key columns on the many-side of relationships, so I have done that in the model too.
This is the approach I would use if this were my data model, especially if Table A and Table B have columns that are somehow related to Col_A, Col_B, Col_C and give these important context. This approach leaves you with greater freedom to normalize your data model.
Common key in each table
In Power Query (or where you define your tables), add a column that concatenates the important columns into one key column. In Power Query you can simply add a new custom column and the formula will be:
[Col_A]&[Col_b]&[Col_C]
You need this common column in BOTH tables, since Power BI does not allow relationships formed by a combination of columns, only single-column relationships. Once this is done, you add a single table in the data model using the same style of DAX code as used previously, but you now also need more columns for it to make sense:
Dim_All =
DISTINCT (
UNION (
SELECTCOLUMNS (
'Table A' ,
"Key" , [Key] ,
"Col_A" , [Col_A] ,
"Col_B" , [Col_B]
),
SELECTCOLUMNS (
'Table B' ,
"Key" , [Key] ,
"Col_A" , [Col_A] ,
"Col_B" , [Col_B]
)
)
)
Connect your tables using the Key columns, but make sure to specify the correct 1-many setting, depending on your data it might create a 1-1 relationship instead, but you want to avoid this for this data model.
You need to create shared dimension tables and a star schema. When you create the appropriate 1-to-many relationships, the filter will propagate automatically for you.

How to Crossjoin or Create a Cartesian Product in Power Query

Can I use power query to combine two tables, so that each rows in table 1 contains all rows in table 2.
For example table 1 includes: customer a, customer b, customer c
table 2 includes: product 1, product 2.
I want to combine two tables into table 3: customer a product 1, customer a product 2, customer b product 1, customer b product 2, customer c product 1, customer c product 2
Yes, it is called a Cartesian join.
Add a column to table 1 with the following code
= Table2
Then expand to new rows by clicking the arrows at the top of the column.
Plain vanilla, you can find a simple example in the Microsoft documentation: Cross-Join

Aaggregate fact table sales based on a dim table column that are related through another dimension table in power BI

I have a situation, I want to get the reseller sales for "WASHINGTON REGION"; the database is "AdventureWorksDW2019" and I have the column relation as follows:
The geography details are populated in "DimGeography" table,
The reseller details are populated in "DimReseller" table, where each geography, say in my case, WASHINGTON could have more then reseller; hence, there is many-to-one relation between "DimReseller" and "DimGeography" and the column in relation is "GeographyKey"
The fact table "FactResellerSales" table is populated with reseller-sales; hence there is many-to-one relation between "FactResellerSales" and "DimReseller" tables; the column in relation is "ResellerKey"
--and the fact table has indirectly relation with "DimGeography" table
I am struggling generate a DAX query to get reseller-sales total belonging to "Washington"; could anyone help me understand to achieve this?
Thank you for giving your valuable time; pls find the screenshot of the schema diagram attached to this email.

I have find out the mismatch between the two tables in power BI

I have 2 tables :
1st table has 2 columns : A Ticket Id B Combo
Ticket Id has the ticket numbers and Combo column has the Incident Status values and these values can be same for many tickets ids.
2nd Tables has 2 columns : A Compare Combo B Match
Compare combo has the Incident Status values and Match column has Yes or No.
Now we need to check each Combo value of first table with the Compare column of second table and if the Match column has the value Yes then it should be there in the BI report.
The things I have tried
LookupValue: Giving error that only single value is allowed.
If: Not allowed because there is no relationship between two tables.
It sounds like you simply need to create a relationship between the two tables on field Combo, then filter your report / visualisation based on field Table2[Match] = Yes

Power BI inactive relationships

I have an active relationship between table A and B that can’t be deactivated. Now, I have a inactive relationship between the same two table and I need to use this relationship as a filter for both. What can I do?
I have tried everything and I always manage to filter only one table.
Thanks everyone in advance
Ed
Concatenate both column of each table on which relations can be created and create a new relationship on this newly created column this will help u to filter the report using both the columns
Eg:- Table 1 - Relation ship columns are C1 and C2
Table 2 - Relationship column are C3 and C4
create a new column in table 1 say RC1 using dax Concatenate(c1,c2) and in table 2 say RC2 using
Concatenate(c3,c4) now create a realtionship on RC1 and RC2 (both side relationship)