Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Issue with sorting a matrix columns

Hi everyone, 
I had a request to have totals of x months on the left side of a matrix table. like in the example below. 

After researching, I found a method that worked with this article. https://4pbi.com/power-bi-matrix-totals-on-the-left/ Which requires creating a calculated table with distinct values of the lifetime in months.
Totalstable = UNION(
    DISTINCT(Sales[lifetimeInMonths]),
    DATATABLE("lifetimeInMonths", STRING, {{"2 months"}}
    ))

and then I have to create the following measures. 

2_months= IF(SELECTEDVALUE('Totalstable '[lifetimeInMonths]) = " 2 months", 1, 0)

SalesWithTotal = IF([2_months], CALCULATE(SUM(Sales[Sales]), 'Totalstable '[lifetimeInMonths] in {1,2}, SUM(Sales[Sales]))
This works, However, since the calculated column lifetimeInMonths is now a text field, I now have a issue with sorting it the right way.
I created a lookup table like this to help with the sort. But for whatever reason, my measure SalesWithTotal then doesn't show my improvised 2_months result anymore


I have officially ran out of ideas. I tried some other things, and I got circular dependency errors.

I'm truly looking forward to your help. 

Best regards.

3 Replies

  • ypu can create a second column and sort the table using that column as reference, them when used on the visual you will have that exact order on the table put it directly on the table column and get a blank square on top of the visual group it and there you go 😛

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    PaulDBrown, this solution worked me. Soo grateful 🙂