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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
JimJim
Responsive Resident
Responsive Resident

Matrix Layout

Hi Guys,

The business have asked me to build a table comparing months in the following format:

JimJim_0-1661242475630.png

 

I have the measures in place but my table looks like this:

JimJim_1-1661242593098.png

Using my current measures, is it possible to replicate the layout requested by the business?

In my table I have 'Show values in rows' = TRUE and here are my measures:

 

Quote Count = DISTINCTCOUNT(proposal_primary[proposal_number])

Quote Count PY = 
VAR CurrentYearMonthNumber = SELECTEDVALUE ( 'Time'[YearMonthKey] )
VAR PreviousYearMonthNumber = CurrentYearMonthNumber - 12
VAR Result =
    CALCULATE (
        [Quote Count],
        REMOVEFILTERS ( 'Time' ),
        'Time'[YearMonthKey] = PreviousYearMonthNumber
    )
RETURN
    Result

Quote Variance % = 
 DIVIDE([Quote Count] - [Quote Count PY], [Quote Count PY], 0)

 

1 ACCEPTED SOLUTION

See if this works for you.

First, create a new table with the structure you need for the matrix columns:

 

Matrix Columns =
VAR _periods =
    SUMMARIZE ( 'time', 'time'[Month], 'time'[YearMonth] )
VAR _Other = { ( "Same Month PY", 1000000 ), ( "Var", 2000000 ) }
RETURN
    UNION ( _periods, _Other )

 

Matrix columns.png

 Leave this table unrelated in the model.

Next create two measures (one for Count and the other for Value) following this pattern:

 

Quote Count Summary =
VAR _SelPeriod =
    SELECTEDVALUE ( 'time'[YearMonth] )
VAR _PY = [Quote Count PY]
VAR _VR =
    FORMAT ( [Quote Count Variance (%)], "percent" )
RETURN
    SWITCH (
        SELECTEDVALUE ( 'Matrix Columns'[YearMonth] ),
        _SelPeriod, [Quote Count],
        1000000, _PY,
        2000000, _VR
    )

 

Next create the matrix using the 'Matrix Columns[Month]' as the columns, add both measures and format to be shown on rows, add some conditional formatting and a dynamic title and you will get this:

MC.gif

 I've attached the sample PBIX file





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

10 REPLIES 10
JimJim
Responsive Resident
Responsive Resident

Thanks for that. Will the months be static (current vs PY) or a dynamic selection?





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.






JimJim
Responsive Resident
Responsive Resident

You're welcome

 

There will be a slicer at the top allowing users to select a month, comparison will always be between selected month and the same month for the previous year. Granularity will never go below month

See if this works for you.

First, create a new table with the structure you need for the matrix columns:

 

Matrix Columns =
VAR _periods =
    SUMMARIZE ( 'time', 'time'[Month], 'time'[YearMonth] )
VAR _Other = { ( "Same Month PY", 1000000 ), ( "Var", 2000000 ) }
RETURN
    UNION ( _periods, _Other )

 

Matrix columns.png

 Leave this table unrelated in the model.

Next create two measures (one for Count and the other for Value) following this pattern:

 

Quote Count Summary =
VAR _SelPeriod =
    SELECTEDVALUE ( 'time'[YearMonth] )
VAR _PY = [Quote Count PY]
VAR _VR =
    FORMAT ( [Quote Count Variance (%)], "percent" )
RETURN
    SWITCH (
        SELECTEDVALUE ( 'Matrix Columns'[YearMonth] ),
        _SelPeriod, [Quote Count],
        1000000, _PY,
        2000000, _VR
    )

 

Next create the matrix using the 'Matrix Columns[Month]' as the columns, add both measures and format to be shown on rows, add some conditional formatting and a dynamic title and you will get this:

MC.gif

 I've attached the sample PBIX file





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.






JimJim
Responsive Resident
Responsive Resident

@PaulDBrown , thank you so much, this is amazing. I won't pretend I understand completely what is going on but I will take some time to work it out. 

I have several other measures I need to add to the matrix, is it easy to add to it?

Btw, I'd be happy to work through  the process if that helps. I wrote a blog post about custom matrix layouts which might also help:

Creating a custom matrix layout 





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.






JimJim
Responsive Resident
Responsive Resident

I really appreciate the offer, I spent some time with your pbix and have a much better understanding of what you have done. I would say the only thing I am not 100% on is the SWITCH(SELECTEDVALUE part but leave it with me 😊

Thank you for sharing your blog post, I have bookmarked it and will definitely read it once I find some time.

Sure. Just create the measures following the pattern of the measure shown. (BTW I edited the conditional formatting measures. I uploaded a new file, but It may have been after you looked at the post, so download the new file just in case).
Let us know if you have any further issues.





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.






PaulDBrown
Community Champion
Community Champion

any chance you can share some dummy data?

Also...I take it you wish to compare two specific months, correct? If so, how will the user select the months to be depicted?





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.






JimJim
Responsive Resident
Responsive Resident

Hi Paul, 

Apologies, let me knock up some test data and I'll share a pbix

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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