Forum Discussion

hainguyen28's avatar
hainguyen28
Regular Visitor
1 year ago

Add a row header for matrix

Currently, I have this matrix in power BI that shows different cost elements of different countries in different dates. There are many different cost elements that the use can filter through.

 

Right now, I am told to add a new column for the "Depreciation" cost element across different countries of the latest date as a fixed column. Essentially, this column will serve as a benchmark for other cost elements, and won't change no matter what cost element is chosen. 

 

For example, if the user select "CAPEX" cost element, the matrix will look something like this:
- 1st column: Countries

- 2nd colunn: "Depreciation" cost of Jan 7th, 2020

- 3rd-9th column: "CAPEX" cost of Jan 1st - Jan 7th, 2020

 

Does anyone know how to do this?

4 Replies

  • Hi hainguyen28 ,

     

    For this you can use a calculation group that will get that value that you need.

     

    Create a calculation group with two calculation items:

    Depreciation =
    VAR _MaxDate = MAXX(ALLSELECTED(Calendar[Date]))
    Return
    
     IF(ISINSCOPE(dCalendario[Data]), BLANK(), 
    CALCULATE([Depreciation], Calendar[Date] = _MaxDate))
    
    Other Elements = SELECTEDMEASURE()
    
    

    Now add the measure that you want to have on the other columns and apply the calculation item to the columns of your matrix:

     

    The matrix must only have the measure that you want to have detail by day do not add any other metric the calculation group will return the correct measure for depreciation.

     

     

    • hainguyen28's avatar
      hainguyen28
      Regular Visitor

      Hi MFelix , thanks for your reply. I am trying to replicate your code, however, I don't understand what dCalendario[Data] is in your code. This is how my table looks like:

      What would be the equivalent of dCalendario[Data] in your code?

    • hainguyen28's avatar
      hainguyen28
      Regular Visitor

      Hi MFelix,

       

      Thanks for replying. I am trying to replicate your code; however, I don't understand what dCalendario[Data] means in your code.

       

      This is how my data table looks like:

      "Depreciation" and "CAPEX" are all under "Cost Element".

      What would be equivalence of your code using my table?

       

      • MFelix's avatar
        MFelix
        Super User

        Hi hainguyen28 ,

         

        The dCalendario[Data] is the date column that you are using on your visual, apologies for not translating it.