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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
WAB_Reports
Helper I
Helper I

1 Report 2 Tables (3 Repair types - maybe) and Summaries for budgets

Hello all,

 

First let me thank the community for the help so far in my new journey (after being tossed into this) in Power Bi, DAX and everything else that falls under it. I have a report I'm trying to build with a trend of budgets vs cost for multiple sites and vehicle types (and maybe repair types). Here are the two sample tables I'm basing this on (both are SQL sourced, same DB different tables and are actually much larger with other data points, such as work order IDs for table 2 etc):

 

Table 1: site_veh_budget

 

SiteVehicle TypeDate (D/M/Y)Budget
ACar1/1/202010000
ATruck1/1/202020000
AMotorcycle1/1/20205000
BCar1/1/202012000
BTruck1/1/202015000
CMotorcycle1/1/20205500
CCar1/1/20208000
ACar1/11/20208888
ATruck1/11/202011000
AMotorcycle1/11/20205200
BCar1/11/202012000
BTruck1/11/202015000
CMotorcycle1/11/20205300
CCar1/11/20209000

 

Table 2: site_veh_repair (this is based on work or purchase orders/tickets)

 

SiteVehicle TypeDate (D/M/Y)Repair TypeCost
ATruck6/1/2020OOW333.45
CCar3/11/2020W580.2
ATruck12/1/2020M75.5
CCar20/11/2020M450
BCar11/8/2020M92.6
BTruck12/1/2020OOW56.56
ACar11/11/2020W890.02
CMotorcycle20/1/2020W785.36
BTruck7/11/2020W2100.56
AMotorcycle14/1/2020M233.51
CMotorcycle7/11/2020M200.2
AMotorcycle22/3/2020OOW86.66
ATruck22/3/2020W1110.36
........

 

What I'm looking to do (still haven't picked a chart type) is take the monthly sums of each site+vehicle type per month (Table 2) and then site+vehicle type+total budget per month (Table 1) with a result of (Table or measures??) ==> (site+vehicle type+total budget per month) - (Site+totals per vehicle type per month).

 

Example:

SiteVehicle TypeDate (D/M/Y)BudgetSite TotalDifference
ACar1/11/202088889547-659
ATruck1/11/20201100086542346
AMotorcycle1/11/202052004589611
BCar1/11/20201200014823-2823
BTruck1/11/20201500018367-3367
CMotorcycle1/11/202053004823477
CCar1/11/2020900011852-2852

 

Bonus?! Should I build table 3 if I later want to expand the reportability?

 

SiteVehicle TypeDate (D/M/Y)total Cost OOWtotal Cost Wtotal Cost Mtype totals
ACar1/11/2020620045828899547
ATruck1/11/20205100122123338654
AMotorcycle1/11/2020154724126304589
BCar1/11/202081004674204914823
BTruck1/11/202056005296747118367
CMotorcycle1/11/2020320058710364823
CCar1/11/2020102545981000

11852

 

My relationship is set to be many to many for Site in both tables. I have the date using the first of the month as right now I'm only needing data per month.

1 ACCEPTED SOLUTION
sevenhills
Super User
Super User

In my view, you should avoid many-to-many

 

Data model and relationships

1. Create master list of Site from both tables

2. Create master list of Vehicle from both tables

3. Link master - Site, Vehicle, to both site_veh_budget, site_veh_repair. By doing steps 1 to 3, you are avoiding many-to-many.  

 

sevenhills_1-1606766192422.png

 

4. Create measure in site_veh_repair as "Diff Measure"

             Diff Measure 2 = Sumx(site_veh_budget, site_veh_budget[Budget]) - sumx(site_veh_repair, site_veh_repair[Cost])

 

Diff Measure = Sum(site_veh_budget[Budget]) - sum(site_veh_repair[Cost])

 

Adjust the formula for the dates, if you want like month and year to be considered

 

Coming to table visual, it will be easy drag ... 

 

sevenhills_0-1606766148792.png

=============================

Other way is to customize only for your requirement, https://community.powerbi.com/t5/Desktop/calculate-target-vs-total-sale/m-p/196598 

View solution in original post

4 REPLIES 4
v-easonf-msft
Community Support
Community Support

Hi, @WAB_Reports 

Could you please tell me whether your problem has been solved?
If it is,  please mark the helpful replies or add your reply as Answered to close this thread.
It will help other community members easily find the solution when they get the similar issue.

Best Regards,
Community Support Team _ Eason

 

sevenhills
Super User
Super User

I tried uploading the .pbix file but I did not find the option, so I have to do the screenshots.

(Previously, I was able to upload files; Now it is not allowing with the chrome/edge browser. Has to check why ... out of thread context, fyi)

sevenhills
Super User
Super User

In my view, you should avoid many-to-many

 

Data model and relationships

1. Create master list of Site from both tables

2. Create master list of Vehicle from both tables

3. Link master - Site, Vehicle, to both site_veh_budget, site_veh_repair. By doing steps 1 to 3, you are avoiding many-to-many.  

 

sevenhills_1-1606766192422.png

 

4. Create measure in site_veh_repair as "Diff Measure"

             Diff Measure 2 = Sumx(site_veh_budget, site_veh_budget[Budget]) - sumx(site_veh_repair, site_veh_repair[Cost])

 

Diff Measure = Sum(site_veh_budget[Budget]) - sum(site_veh_repair[Cost])

 

Adjust the formula for the dates, if you want like month and year to be considered

 

Coming to table visual, it will be easy drag ... 

 

sevenhills_0-1606766148792.png

=============================

Other way is to customize only for your requirement, https://community.powerbi.com/t5/Desktop/calculate-target-vs-total-sale/m-p/196598 

Thanks @sevenhills ! I'll work with this and see how it comes out!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.