Forum Discussion

trinachung's avatar
trinachung
Helper I
6 years ago
Solved

Visual table cannot show correctly

I have below sales & staff cost data and have created below measure to sum up the total staff cost a) staff costs with brand "All" are splitted into Brand A, B, C by "Sales Ratio by Brand", b) staff costs with Brand A, B, C are sum up by brands directly.  When I use the measure in the visual table, the data cannot be shown correctly.  Don't know if the measure is incorrect or the relatioship mapped incorrectly.

 

Staff Cost = calculate(sum('Individual Staff Expenses'[Total Staff Expenses by Individual]), FILTER('Individual Staff Expenses','Individual Staff Expenses'[Brand]="All"))*CALCULATE(sum('Sales Data'[Sales Ratio by Brand]),ALLEXCEPT('Sales Data','Sales Data'[Dept],'Sales Data'[Brand])) + calculate(sum('Individual Staff Expenses'[Total Staff Expenses by Individual]),filter('Individual Staff Expenses','Individual Staff Expenses'[Brand]<>"All"),ALLEXCEPT('Sales Data','Sales Data'[Dept]))

 

Sales Data

Total Staff Expense by Dept

Individual Staff Expenses

Individual Cost Ratio by Salary = '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 = related('Staff Expenses by Dept'[Total Staff Expenses])*'Individual Staff Expenses'[Individual Cost Ratio by Salary]

 

Relationship

Table

My expected result is using the master lists of "Brand" & "Dept" to show below table:

DeptBrand ABrand BBrand CTotal
OPS A     568.18  1,931.820  2,500.00
OPS B  1,500.0000  1,500.00
OPS C0     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

 

However, when I use the master list of "Brand" & "Dept", the data only show the total value.

When I use the Column "Brand" under Sales Data, it can only show the splitted cost of brand "All" correctly but not the total cost with different brands.

When I use the Column "Brand" under Individual Staff Expenses, it can only show the total cost with different brands correctly but not the splitted cost of brand "All".

  • MFelix's avatar
    MFelix
    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.

10 Replies

    • trinachung's avatar
      trinachung
      Helper I

      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?

      DeptBrand ABrand BBrand CTotal
      OPS A     568.18  1,931.820  2,500.00
      OPS B  1,500.0000  1,500.00
      OPS C0     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