Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
mruhullah
Helper II
Helper II

How to show Columns one after another in matrix

Need help to place Revenue, Forecast and Plan one after another in Matrix. 

I wanted to see the below result. 

 

your help will be much appreciated

 

11.jpg

1 ACCEPTED SOLUTION

There's is no way around creating a new table for the matrix setup. You can however avoid the period table if you so wish, and just use TREATAS in your measures:

model 3.png

 and this measure:

 

MEASURE formatrix =
    VAR _Revenue =
        CALCULATE (
            SUM ( fTable[Revenue] ),
            TREATAS ( VALUES ( 'Matrix Columns Setup'[FY-Q] ), 'Date Table'[FY-Q] )
        )
    VAR _Forecast =
        CALCULATE (
            SUM ( fTable[Forecast] ),
            TREATAS ( VALUES ( 'Matrix Columns Setup'[FY-Q] ), 'Date Table'[FY-Q] )
        )
    VAR _Plan =
        CALCULATE (
            SUM ( fTable[Plan] ),
            TREATAS ( VALUES ( 'Matrix Columns Setup'[FY-Q] ), 'Date Table'[FY-Q] )
        )
    RETURN
        SWITCH (
            SELECTEDVALUE ( 'Matrix Columns Setup'[Order] ),
            1, _Revenue,
            2, _Forecast,
            3, _Plan
        )

 

result 2.png

 

New file attached

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

6 REPLIES 6
mruhullah
Helper II
Helper II

Thanks but my model is already complex and table got derived from 7 different tabnle based on DAX. this is the result table. 

 

Idea is great and i need to think before i implement this as it is going to make my model more complex.

 

There's is no way around creating a new table for the matrix setup. You can however avoid the period table if you so wish, and just use TREATAS in your measures:

model 3.png

 and this measure:

 

MEASURE formatrix =
    VAR _Revenue =
        CALCULATE (
            SUM ( fTable[Revenue] ),
            TREATAS ( VALUES ( 'Matrix Columns Setup'[FY-Q] ), 'Date Table'[FY-Q] )
        )
    VAR _Forecast =
        CALCULATE (
            SUM ( fTable[Forecast] ),
            TREATAS ( VALUES ( 'Matrix Columns Setup'[FY-Q] ), 'Date Table'[FY-Q] )
        )
    VAR _Plan =
        CALCULATE (
            SUM ( fTable[Plan] ),
            TREATAS ( VALUES ( 'Matrix Columns Setup'[FY-Q] ), 'Date Table'[FY-Q] )
        )
    RETURN
        SWITCH (
            SELECTEDVALUE ( 'Matrix Columns Setup'[Order] ),
            1, _Revenue,
            2, _Forecast,
            3, _Plan
        )

 

result 2.png

 

New file attached

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Thanks @PaulDBrown let me give it a try....

PaulDBrown
Community Champion
Community Champion

Here is one way of setting it up. 

Assuming you have a fact table along these lines

ftable.png

 And you have dimension tables for date and product, so the model looks like this

model 1.png

You need to create two new tables: one for the matrix columns and a bridge table for the periods:

Matrix Columns Setup = 
VAR _Metric = {("Revenue", 1), ("Forecast", 2), ("Plan", 3)}
VAR _Period = VALUES('Date Table'[FY-Q])
RETURN
CROSSJOIN(_Metric, _Period)

setup table.png

 and the period table

period table.pngmodel 2.png

 

Now create this measure for the matrix (based on SUM measures for each metric):

Measure for matrix = 
SWITCH(
    SELECTEDVALUE('Matrix Columns Setup'[Order]),
    1, [Sum Revenue],
    2, [Sum Forecast],
    3, [Sum Plan])

Finally, set up the matrix with the Porduct Table[Product] as rows, the 'Matrix column Setup'[Metric] and the Period[FY-Q] as the columns and the [Measure for matrix] in the values bucket:

matrix.pngresult.png

 Sample PBIX file attached

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Thanks but my model is already complex and table got derived from 7 different tabnle based on DAX. this is the result table. 

 

Idea is great and i need to think before i implement this as it is going to make my model more complex.

 

v-yadongf-msft
Community Support
Community Support

Hi @mruhullah,

 

Is this the result you want?

vyadongfmsft_0-1665108662804.png

 

My test table:

vyadongfmsft_1-1665108899722.png

 

Remember to expand all done one level in the hierarchy:

vyadongfmsft_2-1665109068029.png

 

Best regards,

Yadong Fang

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.