Results 1 to 2 of 2

Thread: Adding multiple columns in Matrix columns
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jul 2019
    Posts
    4
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Adding multiple columns in Matrix columns

    Hi All,

    I am new to power BI and I have requirement to do in power BI where I need to show the some of key metrics in matrix format.

    Here is the my requirement.

    Well I am working for the Textile company where in I need to prepare the reports using Power BI and unfortunately I could not make it. I use matrix for the showing the differences of reports between 2018 and 2019.


    Please check the below screen shot where I need to get the output like mentioned screenshot.



    Please note that %Change in the above table is a measure which I had written % change = DIVIDE(CALCULATE(SUM(Table1[Reports]),Table1[Year]=2019)-CALCULATE(SUM(Table1[Reports]),Table1[Year]=2018),
    CALCULATE(SUM(Table1[Reports]),Table1[Year]=2018))

    When I am trying to add the same measure in my matrix the % change showing
    for the both 2018 and 2019 years and I need it at the end of matrix.



    You may check the my visualization pane to verify the rows and columns.


    Is there any work around for the same issue and I've trying itfor a long time and finally seeking for your help.

    Thanks for your support.






  2. #2
    MrExcel MVP
    Join Date
    Dec 2014
    Location
    Sydney, Australia
    Posts
    1,186
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Adding multiple columns in Matrix columns

    It seems your images didn't post on either thread. This makes it difficult for people to help you. I recommend you see if you can sort that out as there are lots of people willing to help for free - but you have to make it easy for them. You issue is that you have put year on the columns in your report and also a measure. This creates 2 levels of data. The top level is the year and underneath that is the measure. In your case, the years are 2018 and 2019, and the measure is simply showing the % change for 2019 vs 2018, hence the problem. Better to write 3 measures.

    Total 2018 = CALCULATE(SUM(Table1[Reports]),Table1[Year]=2018)
    Total 2019 =
    CALCULATE(SUM(Table1[Reports]),Table1[Year]=2019)
    % change = DIVIDE([Total 2019] -[Total 2018],[Total 2018])

    If you add these 3 measures, it will be at a single level and hence it will do what you want.

    Better still, write these measures
    Code:
    Total This Year = VAR ThisYear = max(Table1[Year])
                             RETURN CALCULATE(SUM(Table1[Reports]),Table1[Year]=ThisYear)
    Total Last Year = VAR LastYear = max(Table1[Year])-1
                             RETURN CALCULATE(SUM(Table1[Reports]),Table1[Year]=LastYear)
    % change = DIVIDE([Total This Year] -[Total Last Year],[Total Last Year)
    Add the 3 measures to the matrix and add a slicer from the year column. When you select the year in the slicer, it will update to show you the selected year and prior year
    Matt Allington is a professional Power BI Consultant, Power BI Trainer and Microsoft MVP based in Sydney Australia. Matt is author of the Power BI book Supercharge Power BI and the Power Pivot Book Supercharge Excel.
    What is Power BI?

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •