Forum Discussion
Best Practice Question
- 6 years ago
Hi VulcanPromance ,
To what I can understand here you issue is based on the calculation of the percentage of Yearly costs per country this can be achieve by making the following measures:
Monthly Price = VAR temp_Table = SUMMARIZE ( 'Price Table'; 'Price Table'[Bundle Name]; 'Price Table'[Price]; "Users"; DISTINCTCOUNT ( Licenses[UserID] ) ) RETURN SUMX ( temp_Table; 'Price Table'[Price] * [Users] ) Yearly Price = [Monthly Price] * 12I'm assuming the Yearly is just multiplyig by 12 months.
Then you need to calculate the percentage of costs per country selected:
% per Country = [Yearly Price] / CALCULATE([Yearly Price];all(Employees[Country]))If you have a country table that should be based on that table and not employees table.
Now just make the measures for the Shared Costs:
Shared_Costs = SUM('Cost Table'[Cost]) // Just used as a auxiliary calculation Shared_Costs_Selected_Countries = [% per Country] * [Shared_Costs] Markup 5% = [Shared_Costs_Selected_Countries] * 0,05 Overhead 10% = [Shared_Costs_Selected_Countries] * 0,1 Fee 3% = [Shared_Costs_Selected_Countries] * 0,03 BO4 Reporting 12% = [Shared_Costs_Selected_Countries] * 0,12 Total Shared Costs = [Shared_Costs_Selected_Countries]+Measure_Table[Markup 5%]+[Overhead 10%]+[Fee 3%]+[BO4 Reporting 12%]This values will give you the calculation for the shared costs now you only need to sum the value of the last measure with the Yearly costs and you are all set:
Total Costs Per country = [Yearly Price] + [Total Shared Costs]Check the image below and the PBIX file attach.
Any questions please tell me.
- 6 years ago
Hi VulcanPromance ,
Add the following measure to your calculation:
Count of users = CALCULATE ( MAXX ( SUMMARIZE ( 'Price Table'; 'Price Table'[Bundle Name]; 'Price Table'[License Name]; "@User_Count"; DISTINCTCOUNT ( Licenses[UserID] ) ); [@User_Count] ); ALLEXCEPT ( 'Price Table'; 'Price Table'[Bundle Name] ) )Now just need to redo the Montlhy price and everything else will calculate accordingly:
Monthly Price = VAR temp_Table = SUMMARIZE ( 'Price Table'; 'Price Table'[Bundle Name]; 'Price Table'[Price]; "Users"; [Count of users] ) RETURN SUMX ( temp_Table;'Price Table'[Price] * [Users])Just added the Count of Users in your measure. There is a small difference but believe is rounding.
Check result attach.
You may take a look at the post below.
- VulcanPromance6 years agoHelper II
actually this didnt solve my question.. it autosolved it it seems. MFelix do you have more insight?
- MFelix6 years agoSuper User
Hi VulcanPromance ,
To what I can understand here you issue is based on the calculation of the percentage of Yearly costs per country this can be achieve by making the following measures:
Monthly Price = VAR temp_Table = SUMMARIZE ( 'Price Table'; 'Price Table'[Bundle Name]; 'Price Table'[Price]; "Users"; DISTINCTCOUNT ( Licenses[UserID] ) ) RETURN SUMX ( temp_Table; 'Price Table'[Price] * [Users] ) Yearly Price = [Monthly Price] * 12I'm assuming the Yearly is just multiplyig by 12 months.
Then you need to calculate the percentage of costs per country selected:
% per Country = [Yearly Price] / CALCULATE([Yearly Price];all(Employees[Country]))If you have a country table that should be based on that table and not employees table.
Now just make the measures for the Shared Costs:
Shared_Costs = SUM('Cost Table'[Cost]) // Just used as a auxiliary calculation Shared_Costs_Selected_Countries = [% per Country] * [Shared_Costs] Markup 5% = [Shared_Costs_Selected_Countries] * 0,05 Overhead 10% = [Shared_Costs_Selected_Countries] * 0,1 Fee 3% = [Shared_Costs_Selected_Countries] * 0,03 BO4 Reporting 12% = [Shared_Costs_Selected_Countries] * 0,12 Total Shared Costs = [Shared_Costs_Selected_Countries]+Measure_Table[Markup 5%]+[Overhead 10%]+[Fee 3%]+[BO4 Reporting 12%]This values will give you the calculation for the shared costs now you only need to sum the value of the last measure with the Yearly costs and you are all set:
Total Costs Per country = [Yearly Price] + [Total Shared Costs]Check the image below and the PBIX file attach.
Any questions please tell me.
- VulcanPromance6 years agoHelper II
Thats pretty sweet. But the original issue is the count of userID's.. as you can see on facility management it counts 9 unique users. And thats the correct amount of users. However, the cost for the licenses should be based on the highest amount of users with in each Bundle..
Example
Facility managment has 2 license types..
Workorders - 8 users
Helpdesk Backoffice - 3 users
a user can have both or only 1 license of the above. So the unique users are 9, but the cost should be based on the license type with most users i.e 8...
And thats where I begin to struggle, cause using normal measures to calculate the cost (using various of ways to find the max value) seems to fail. Hence the question, what is the best practice to calculate max and get it to work in the calculations you've used above.. 🙂
I've purchased a guide to DAX book now, so that I can read more up on the language.. but would appreciate a solution on this from an expert like yourself.. 🙂