Forum Discussion
Visual table cannot show correctly
- 6 years ago
Hi trinachung ,
Keeping the originial relationship model you have you need to create the following measures:
Individual Cost Ratio by Salary = SUM ( 'Individual Staff Expenses'[Salary by Cost Split] ) / CALCULATE ( SUM ( 'Individual Staff Expenses'[Salary by Cost Split] ); ALLEXCEPT ( 'Individual Staff Expenses'; 'Individual Staff Expenses'[Dept] ) ) Total Staff Expenses by Individual AUX = IF ( SELECTEDVALUE ( 'Individual Staff Expenses'[Brand] ) = "All"; SUM ( 'Total Staff Expenses'[Total Staff Expenses] ) * CALCULATE ( [% sales]; FILTER ( ALL ( 'Sales Data'[Brand] ); 'Sales Data'[Brand] = SELECTEDVALUE ( Brand[Brand] ) ) ); CALCULATE ( SUM ( 'Total Staff Expenses'[Total Staff Expenses] ) * [Individual Cost Ratio by Salary]; FILTER ( 'Individual Staff Expenses'; 'Individual Staff Expenses'[Brand] = SELECTEDVALUE ( Brand[Brand] ) ) ) ) + 0 % sales = SUM('Sales Data'[Sales])/CALCULATE(SUM('Sales Data'[Sales]);ALL('Sales Data')) Total Staff Expenses by Individual = IF ( HASONEVALUE ( Dept[Dept] ); SUMX ( Brand; [Total Staff Expenses by Individual AUX] ); IF ( HASONEVALUE ( Brand[Brand] ); SUMX ( Dept; [Total Staff Expenses by Individual AUX] ); SUM ( 'Total Staff Expenses'[Total Staff Expenses] ) ) )Now just setup you table as needed.
Your issue was related with the ALL part of the split by brand of the department costs, so you need to force for those the split by % of sales.
As you can see in the file I have attach I have no additional calculated columns all measures.
Check the result in attach PBIX file.
Thanks for your help, amitchandak !!
I've tried to link the relationship again per your suggestion. However, the table can only show this:
Is it possible to divide the cost of SUP A & SUP B by "Sales Ratio by Brand" into Brand A, B, C as well and shown in the same table just like below?
| Dept | Brand A | Brand B | Brand C | Total |
| OPS A | 568.18 | 1,931.82 | 0 | 2,500.00 |
| OPS B | 1,500.00 | 0 | 0 | 1,500.00 |
| OPS C | 0 | 702.00 | 1,098.00 | 1,800.00 |
| SUP A | 483.87 | 1,032.26 | 483.87 | 2,000.00 |
| SUP B | 241.94 | 516.13 | 241.94 | 1,000.00 |
| Total | 2,793.99 | 4,182.21 | 1,823.81 | 8,800.00 |
trinachung , Can you share sample data in table format.
- trinachung6 years agoHelper I
amitchandak Please find the data as below:
Sales Data
Dept Brand Sales OPS A Brand A 100 OPS A Brand B 200 OPS B Brand A 50 OPS C Brand B 120 OPS C Brand C 150 Total Staff Expenses
Dept Total Staff Expenses OPS A 2000 OPS B 1000 OPS C 2500 SUP A 1500 SUP B 1800 Individual Staff Expenses
Staff Dept Brand Cost Split Salary by Cost Split Staff A SUP A All 1 500 Staff B SUP A All 1 200 Staff C SUP A All 1 300 Staff D SUP B All 1 200 Staff E SUP B All 1 300 Staff F OPS A Brand A 0.8 200 Staff F OPS A Brand B 0.2 50 Staff G OPS A Brand B 1 230 Staff H OPS A Brand B 1 400 Staff I OPS B Brand A 1 300 Staff J OPS B Brand A 1 400 Staff K
OPS C Brand B 0.4 240 Staff K OPS C Brand C 0.6 360
Staff L OPS C Brand B 1 150 Staff M OPS C Brand C 1 250 Brand
Brand Brand A Brand B Brand C Dept
Dept OPS A OPS B OPS C SUP A SUP B - MFelix6 years agoSuper User
Hi trinachung ,
Keeping the originial relationship model you have you need to create the following measures:
Individual Cost Ratio by Salary = SUM ( 'Individual Staff Expenses'[Salary by Cost Split] ) / CALCULATE ( SUM ( 'Individual Staff Expenses'[Salary by Cost Split] ); ALLEXCEPT ( 'Individual Staff Expenses'; 'Individual Staff Expenses'[Dept] ) ) Total Staff Expenses by Individual AUX = IF ( SELECTEDVALUE ( 'Individual Staff Expenses'[Brand] ) = "All"; SUM ( 'Total Staff Expenses'[Total Staff Expenses] ) * CALCULATE ( [% sales]; FILTER ( ALL ( 'Sales Data'[Brand] ); 'Sales Data'[Brand] = SELECTEDVALUE ( Brand[Brand] ) ) ); CALCULATE ( SUM ( 'Total Staff Expenses'[Total Staff Expenses] ) * [Individual Cost Ratio by Salary]; FILTER ( 'Individual Staff Expenses'; 'Individual Staff Expenses'[Brand] = SELECTEDVALUE ( Brand[Brand] ) ) ) ) + 0 % sales = SUM('Sales Data'[Sales])/CALCULATE(SUM('Sales Data'[Sales]);ALL('Sales Data')) Total Staff Expenses by Individual = IF ( HASONEVALUE ( Dept[Dept] ); SUMX ( Brand; [Total Staff Expenses by Individual AUX] ); IF ( HASONEVALUE ( Brand[Brand] ); SUMX ( Dept; [Total Staff Expenses by Individual AUX] ); SUM ( 'Total Staff Expenses'[Total Staff Expenses] ) ) )Now just setup you table as needed.
Your issue was related with the ALL part of the split by brand of the department costs, so you need to force for those the split by % of sales.
As you can see in the file I have attach I have no additional calculated columns all measures.
Check the result in attach PBIX file.
- trinachung6 years agoHelper I
Great thanks for the solution, MFelix !!