Power BI Report with Bridge Table

≡放荡痞女 提交于 2021-02-17 02:42:30

问题


I am trying to use Power BI with my SQL DB. We have a three layer structure

  1. A Main table, with information about the year and unique key for each firm
  2. A bridge table which an information about the type of the firm
  3. Many end Tables with information about sales and stuff

On some occasions these end tables are jointly used by different firm types and some only by one firm type.

When I load the tables into Power BI all the relationships are correctly imported and I was expecting no issue to create a summary table like Sum(Var) by Year, even though I am getting the Var from an end table and the Year from the main table. However they show the same sum for all years.

I am having a hard time creating a MWE and I do not have access to a remote server.

This picture shows the structure, which is similar to our data base, I did not add the type column. I now created bi directional realtion with the end Tables

Basically I just created a MWE with this data split into 4 tables. I simplified the End tables to just be 1 and 0 and added a third firm

When taking the sums of X and Y, I am getting the same value and I would have expected 2 in 2018 and 1 in 2019 for X and 1 in 2018 and 2 in 2019 for Y

I also tried to merge the Year into the bridge table when loading the data, but I still get the wrong results.

I find many post about wrong totals etc. and needing to use different measures, but I do not have any complicated calculations just the sum of the raw data per year.

Anything else I can do to clarify my question? Should i create a new one? I could add the raw data as a csv/xlsx file(s)

thx for the answer which I can accept later given that it solves my MWE, but somehow it does not solve my original problem. As explained in the comment here is my data model:

I am using the Import function from an MS SQL Data Base and your DAX Code

dax1 = sumx(unternehmen; RELATED(at_sonstiges[abschluss_erwartet]))

回答1:


I'm assuming this is what you're after:

I've defined these measures as

SumX = SUMX ( Main_Table, RELATED ( End_Table_X[X] ) )

SumY = SUMX ( Main_Table, RELATED ( End_Table_Y[Y] ) )

This solution does not require a year column on the Bridge_Table or bidirectional filters with the end tables.

Instead of trying to propagate the year, it iterates over all of the rows of the Main_Table (within the local filter context) and essentially does a lookup of X or Y for each row.



来源:https://stackoverflow.com/questions/65197622/power-bi-report-with-bridge-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!