Forum Discussion

gomezc73's avatar
gomezc73
Helper V
2 years ago
Solved

Add a Fix Column to 'Columns subtotal' in Matrix.

Hi Experts,

 

  I have a matrix to show the inventory by three diferent Categories:

  • Uniforms
  • Beverages
  • Food

   That amounts are calculated and Vary by month.

   

    The user can select from the Slicer 1,2 or all categories and the Matrix show a total by Categories selected without issues.

    

      The results is similar to this if all categories are selected.

      

RestaurantBeveragesFoodUniformsTotal
Rst-0125030012001750
Rst-025003508601710
Rst-036004507501800
Rst-048006007002100
Rst-0512001678002167

   

Now, the user wants show in the matrix two additional columns(Initial Setup and Other setup) with Fixed values by Restaurant, but he wants to add the fixed amounts in the 'total'

 

NOTE: that amounts  for Initial Setup and Other setup are fixed By restaurant (no calculations)

 

By Eaxmple:

 

If the user ONLY select Beverages and Food, the TOTAL must sum Beverages and food PLUS Initial setup and Other setup.

 

I added the new columns in the row fields and it are showed in the Matrix.

 

RestaurantInitial setupOther SetupBeveragesFoodTotal
Rst-0110050250300700
Rst-021201505003501120
Rst-033001206004501470
Rst-04256808006001736
Rst-052135012001671630

 

How can I do that, if in the categories I only have the three categories that I already mentioned

 

In other words i need that the last colum (Total) summarize the amounts in categories selected Plus the two fixed values(Initial Setup and Other setup). Is it Possible?

 

I really appreciate your help..

    

  

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi gomezc73 ,

    You can follow these steps to solve your problem:

    1.Unpivot all categories column.

     

    2.Add a column.

     

    Column =
    'Table'[Initial setup] + 'Table'[Other Setup]
    

     

     

    3.Add a measure.

     

    total =
    
    CALCULATE (
    
        SUM ( 'Table'[Value] ),
    
        FILTER ( 'Table', 'Table'[Restaurant] = SELECTEDVALUE ( 'Table'[Restaurant] ) )
    
    )
    
        + SELECTEDVALUE ( 'Table'[Column] )

     

     

    Output:

     

    How to Get Your Question Answered Quickly - Microsoft Fabric Community

    If it does not help, please provide more details with your desired out put and pbix file without privacy information.

     

    Best Regards,

    Yifan Wang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi gomezc73 ,

    You can follow these steps to solve your problem:

    1.Unpivot all categories column.

     

    2.Add a column.

     

    Column =
    'Table'[Initial setup] + 'Table'[Other Setup]
    

     

     

    3.Add a measure.

     

    total =
    
    CALCULATE (
    
        SUM ( 'Table'[Value] ),
    
        FILTER ( 'Table', 'Table'[Restaurant] = SELECTEDVALUE ( 'Table'[Restaurant] ) )
    
    )
    
        + SELECTEDVALUE ( 'Table'[Column] )

     

     

    Output:

     

    How to Get Your Question Answered Quickly - Microsoft Fabric Community

    If it does not help, please provide more details with your desired out put and pbix file without privacy information.

     

    Best Regards,

    Yifan Wang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.