Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
kobkabnaja
Helper II
Helper II

General question - Relationship vs. Merging and the filtering problems

Hi Community,

I posted a quetion yesterday regarding handling data with different granularities (at this post). After working on it all day, I realized the issue might not be with joining the data, but rather with the data modeling itself. To illustrate this problem, here are the hypothetical datasets that resemble what I am working with:

 

Expenditure: (columns: Date, Department, Sub-Department, Code, Type, Amount)

DateDepartmentSub-DepartmentCodeTypeAmount
10/16/2024A1010001F1
10/16/2024A1010001G2
10/16/2024A1010002C3
10/16/2024A1110001F4
10/16/2024B1110001F5
10/16/2024B1110003G6
10/16/2024C2110001C7
10/16/2024C2110002C8
10/16/2024C1210005F9

 

Budget: (Year: Date, Department, Sub-Department, Code, Type, Amount)

YearDepartmentSub-DepartmentCodeTypeAmount
2024A1010001F50
2024A1010001G10
2024A1010002C20
2024B1110001F30
2024B1110003G50
2024C2110002C35
2024C2110001C25
2024C2110002C15
2024C1210005F10

 

Both tables are quite similar, but the Expenditure data is more detailed (daily), where as the Budget data is at the yearly level.I noticed that visualizations change depending on how I used the filter (i.e., using Department in the Expenditure as a filter v.s. using Department in the Budget as a filter).

 

Here are my questions:

  1. Should I continue using relationships to link these datasets? If so, how can I resolve the inconsistent filtering? Do I need to create separate master tables for Department, Sub-Department, Code, and Type to manage this?

  2. To create a relationship between the Budget and Expenditure tables, I created a unique ID by combining Year, Department, Sub-Department, Code, and Type. However, I also need to create a relationship between the Year column in the Budget table and the main Calendar table so I can use time-based filters. Is this the correct approach? I’ve seen few examples of people using more than one active relationship per table in Power BI, so I’m unsure if this is best way.

  3. Could this issue be related to data modeling, or is it possible that I have done the modeling correctly but need to create measures to capture what I want? How would you approach this problem?

  4. I also tried merging the two datasets (full join), but the results were not what I expected. Unlike in other programs, I did not get the common columns after the merge, which led to the same filtering issues. Did I miss a step during the merge, or is there a specific setting I overlooked?

I know this is a long post, and I truly appreciate anyone who takes the time to read through it. If anyone has suggestions, advice, or a solution, I’d be very grateful. I've been stuck on this for two days now, and it's becoming quite frustrating. If it’s easier to explain, I’m happy to jump on a Zoom or Microsoft Teams call. Please feel free to ask if you need any more information.

 

Thanks a ton!

K

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,

Thanks for the solution @Irwan  offered, and i want to offer some more informaion for user to refer to.

hello @kobkabnaja , based on your descriiption and the output you want, i create the following model.

vxinruzhumsft_0-1729219280859.png

Here are the steps:

1.Create the following tables:

Depaerment:

vxinruzhumsft_1-1729219710324.png

SubDepaerment:

vxinruzhumsft_2-1729219734282.png

Code:

vxinruzhumsft_3-1729219749057.png

Type:

vxinruzhumsft_4-1729219769941.png

Calendar:

 

Calendar = CALENDAR(DATE(2024,1,1),DATE(2024,12,31))

 

2.Then create the following relationships:

Department with Expenditure and Budget:one->many

SubDepaRtment with Expenditure and Budget:one->many

Code with Expenditure and Budget:one->many

Type with Expenditure and Budget:one->many

Calendar with Expenditure :one->many

3.Then calculate the following measures:

 

YTD = CALCULATE(SUM(Expenditure[Amount]),DATESYTD('Calendar'[Date]))
BudgetAmount = CALCULATE(SUM(Budget[Amount]),Budget[Year]=YEAR(MAX('Calendar'[Date])))

 

4.Then you can create a chart visual and put the following fields:

vxinruzhumsft_5-1729220382044.png

 

Output

vxinruzhumsft_6-1729220428298.png

If you want to create the slicer, please use the fields of the dimension table  created above.

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi,

Thanks for the solution @Irwan  offered, and i want to offer some more informaion for user to refer to.

hello @kobkabnaja , based on your descriiption and the output you want, i create the following model.

vxinruzhumsft_0-1729219280859.png

Here are the steps:

1.Create the following tables:

Depaerment:

vxinruzhumsft_1-1729219710324.png

SubDepaerment:

vxinruzhumsft_2-1729219734282.png

Code:

vxinruzhumsft_3-1729219749057.png

Type:

vxinruzhumsft_4-1729219769941.png

Calendar:

 

Calendar = CALENDAR(DATE(2024,1,1),DATE(2024,12,31))

 

2.Then create the following relationships:

Department with Expenditure and Budget:one->many

SubDepaRtment with Expenditure and Budget:one->many

Code with Expenditure and Budget:one->many

Type with Expenditure and Budget:one->many

Calendar with Expenditure :one->many

3.Then calculate the following measures:

 

YTD = CALCULATE(SUM(Expenditure[Amount]),DATESYTD('Calendar'[Date]))
BudgetAmount = CALCULATE(SUM(Budget[Amount]),Budget[Year]=YEAR(MAX('Calendar'[Date])))

 

4.Then you can create a chart visual and put the following fields:

vxinruzhumsft_5-1729220382044.png

 

Output

vxinruzhumsft_6-1729220428298.png

If you want to create the slicer, please use the fields of the dimension table  created above.

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Anonymous ,
Thank you so much for your help, I really appreciate it! Your solution works perfectly, except that I had to establish a many-to-many relationship between the Year column in the MASTER_CALENDAR and BUDGET tables. Initially, I solved the issue by merging the two datasets and creating new columns to match common fields, accounting for unmergeable observations. However, your approach is much more efficient and aligns better with Power BI practices.

Since I'm new to Power BI, I used to merge all datasets for analysis, but your method offers a far better way to handle multiple data sources and sets a solid foundation for future projects. Thanks again for your guidance and all the effort you have put in!

Cheers,
Kob

 

Irwan
Super User
Super User

hello @kobkabnaja 

 

the approach may be different from person to person. but here is my thought (might not the best)

 

  1. i would countinue using relationship if joining the data is making another table which kinda redundant (the new one has same informations as both table). Unless you are joining the data outside PBI then import the result to PBI, then i guess that is another way.
  2. Yes, i would use CONCATENATE as you mentioned above. so the relationship will be between those two unique values.Irwan_0-1729132891684.png

    and yes, you need another relationship for Date if you want to use time based filters (the slicer will take value from date table).

    Otherwise, if those tables is exact same but different in single column, i would just combine that value from one table to another table either using PQ or DAX then work in that one table instead of two tables.

  3. Data modeling is something that need to be planned before hand esspecially if you take from multiple sources. Yes, use measure to get your desired result (although you can use calculated column as well).
  4. that might be the best answer for that if you get wrong result.

 

Hope this will help.

Thank you

 

@Irwan  Thanks so much for addressing several key points in my questions. I eventually resolved the issue by merging and combining columns to get the correct values. Your insights were helpful, and I will definitely apply this framework in future projects. I really appreciate your help!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors