Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I am hoping someone can assist.
I have 2 tables of data Table A has all the data contained within it and Table B has unique fields - the relationship is Many to One.
Table A has Columns 'Name', 'Hours Worked', 'Date Logged' and 'Project'
Table B has Columns 'Name', 'Base Day Rate' and 'Base Hourly Rate'
The calcualtion I want is to show the 'Total Cost per Person' - the calculation I did use to start with was:
Total Cost per Person = SUM('TableA'[Hours_Worked]) * SUM('Table B'[Base_Hourly_Rate]), this was then broken down by individual and date logged (please take into account 1 individual has a number of entries against a single day, as they are allocating time against tasks e.g. Person 1 logs 4 entries for 01/06/2016 equating to a total of 7 hours. Using the calculation, I hoped to see how much each task has cost.)
This was showing very weird calculations! As an example, the month of June should have shown a total of £435,653.85 but though Power BI it shows £36,269,076.87!
I am new to Power BI and using DAX, so apolgies if I am missing something obvious but any help would be greatly appreciated.
Many thanks
Solved! Go to Solution.
In this example I managed to fix the issue.
I completed a merge on the 2 tables with the relevant data. This created a column that contained all of the columns from 'Table 2', so I picked 'Hourly Rates'. I then created a calculated column multiplying the 'Hours' column by the 'Hourly Rates' column, this gave me the desired outcome.
Thanks for everyones suggestions and help.
I *believe* what you are seeing in the Total row is that the measure is essentially not contextually filtered. So, in the total row, it is summing all of your values for all of your base hourly rates and then multiplying that by a sum of all of your hours worked.
Essentially:
Instead of: ($125 * 16) + ($150 * 16) = $4,400
you are getting:
($125 + $150) * (16 + 16) = $8,800
Remember, a measure's value is controlled by its context and in the Total row, it is removing all of the context essentially and you are getting a wrong answer as a result.
Thank you for the quick response.
I think I understand what you are suggesting but I am not clear on how I can remedy this issue? Is there an alternative solution to get the right result to show?
I need the total, as I want to be able to show the cost against either the project, month or person. This is vital to the report.
Thanks
Just to add, I have looked at some of the calculation and they dont even seem to be doing that...
Correct Calcualtion | Power BI Calculation | |||||||
Hours | Hourly Rate | Cost | Hours | Hourly Rate | Cost | |||
1 | £ 118.57 | £ 118.57 | 1 | £118.57 | £118.57 | |||
1 | £ 118.57 | £ 118.57 | 1 | £118.57 | £118.57 | |||
2 | £ 118.57 | £ 237.14 | 2 | £118.57 | £237.14 | |||
2.5 | £ 118.57 | £ 296.43 | 2.5 | £118.57 | £296.43 | |||
0.5 | £ 62.14 | £ 31.07 | 0.5 | £62.14 | £31.07 | |||
1 | £ 62.14 | £ 62.14 | 1 | £62.14 | £62.14 | |||
Total | 8 | £598.56 | £863.92 | Total | 8 | £180.71 | £1,445.68 |
It looks as though the calculation (according to Power BI), is taking the total number of hours and multiplying it by the unique values within the hourly rate (£118.57 and £62.14 = £180.71). All I need is the total of the cost (£863.92).
Could this be due to the relationship between the 2 tables?
Hi @JC-80,
Could you please post the sample data of your two tables and post the expected result here? Regrading to the above table, you can simply create a measure to summarize the cost by using the formula: Measure = SUMX(Table1,Table1[Hours]*Table1[Hours Rate]).
Thanks,
Lydia Zhang
In this example I managed to fix the issue.
I completed a merge on the 2 tables with the relevant data. This created a column that contained all of the columns from 'Table 2', so I picked 'Hourly Rates'. I then created a calculated column multiplying the 'Hours' column by the 'Hourly Rates' column, this gave me the desired outcome.
Thanks for everyones suggestions and help.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
97 | |
96 | |
81 | |
74 | |
66 |
User | Count |
---|---|
126 | |
106 | |
105 | |
86 | |
72 |