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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
asa70
Advocate I
Advocate I

Matrix Visual: Combing Two Calculations and Fields Into Visual

Hi all, 

 

I hope you're all doing well.

 

I have a task where I need to showcase two calculations on a Matrix Visual:

asa70_0-1757511817719.png

 

  1. A Yearly Calculation for the ones in Green 
  2. A 12 Month Trailing Calculation for the ones in Orange. 

The DAX for the 2 calculations have been created and work fine individually. It's when I have to combine the 2 measures into visual in the screenshot.

 

These are the rules that were provided:

  1. For the current or max year, only show the 12 Month Trailing Calculation for current/max month, current/max month - 1 and current/max month - 2
  2. For the previous years, only showing YTD 

Any tips or advice on how to show the 2 calculations to get the required view in the screenshot. It would be really appreciated!

 

I have attached the sample data for the screenshot.

 

Kind Regards,
Asa

 

Month YearAttrition
Jan202310
Feb20232
Mar20235
Apr20238
May20239
Jun20232
Jul20236
Aug20230
Sept20237
Oct20237
Nov202310
Dec20236
Jan20249
Feb20249
Mar20240
Apr20241
May20242
Jun20245
Jul20248
Aug20245
Sept20244
Oct202410
Nov20242
Dec20241
Jan20253
Feb20252
Mar20252
Apr20250
May20252
Jun20250
Jul20259
Aug20255
1 ACCEPTED SOLUTION

Hi @v-saisrao-msft, I'm looking into the Paginated Report solution and learning about it first. I will revert back once I have designed the view. Thank you!

View solution in original post

13 REPLIES 13
v-saisrao-msft
Community Support
Community Support

Hi @asa70,

Have you had a chance to review the solution we shared earlier? If the issue persists, feel free to reply so we can help further

 

Thank you.

Hi @v-saisrao-msft, I'm looking into the Paginated Report solution and learning about it first. I will revert back once I have designed the view. Thank you!

Hi @asa70,

Checking in to see if your issue has been resolved. let us know if you still need any assistance.

 

Thank you.

Hi @v-saisrao-msft , Apologies for the late reply. I have started using Power BI Report Builder for the solution.

 

I have a question on how to put the calculations on the same table. Through my exploration I have found 2 ways:

 

  1. Creating a calculated table - How do I ensure that the Yearly Attrition calculation stills shows up and not just the Monthly Attrition calculation?
  2. Creating two datasets and joining the tables - How would that be efficient and will it be relevant for the problem.

I'm still trying to figure out how to build the layout of the table, maybe that's where the solution will be?

 

Kind Regards,

Asanele 

Hi @asa70,

Since you’re now using Power BI Report Builder, you don’t need to create extra calculated tables or join multiple datasets. Just connect to your existing Power BI dataset and add both the Monthly Attrition and Yearly Attrition measures into the same tablix. Paginated reports are built for this type of formatted matrix layout, and using a single dataset keeps things simpler and more efficient.

Supported data sources for Power BI paginated reports - Power BI | Microsoft Learn

Paginated reports in Power BI: FAQ - Power BI | Microsoft Learn

Data retrieval guidance for paginated reports - Power BI | Microsoft Learn

 

Thank you.

Hi @v-saisrao-msft , thank you so much for the feedback. When I use both Yearly and Monthly Attrition calculation, how would I add them in the same dataset?

Hi @asa70,

Please find the below attached pbix file for reference:

vsaisraomsft_0-1762324046409.png

 

Thank you.

Hi @v-saisrao-msft , thank you so much for the feedback. I can see how this would work in Power BI. My question was in reference to Report Builder. How would I ensure that:

1. The Dataset includes both Attrition calculations for Year and Month because there are 2 separate calculations depending on the Year or Month shown in the visual.

2. Showing on the columns the Years and Current Year, with the last 3 months.

 

I hope that helps

 

Kind Regards

Hi @johnt75,

Just checking in to see if you were able to design the view, and if the issue has been resolved.

 

Thank you.

Hi @asa70,

Thank you for the update.

 

v-saisrao-msft
Community Support
Community Support

Hi @asa70,

Thank you @audreygerred,@johnt75, for your insights.

If your primary requirement is to replicate the appearance and formatting of the table with grouped headers and custom spans as shown in your screenshot, then using a Paginated Report would be the more suitable choice for your scenario.

 

Thank you.

 

audreygerred
Super User
Super User

Hi! You will likely be able to achieve this using pagination/Report Builder. It has less rigid formating than a matrix in Power BI due to its pixel perfect nature.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





johnt75
Super User
Super User

I think the easiest way would be to create a calculation group with calculation items for each column, something like

Year - 2 =
VAR LastDateWithValues =
    CALCULATE ( MAX ( Sales[Date] ), REMOVEFILTERS () )
VAR Result =
    CALCULATE (
        SELECTEDMEASURE (),
        'Date'[Year]
            = YEAR ( LastDateWithValues - 2 ),
        REMOVEFILTERS ( 'Date' )
    )
RETURN
    Result

and 

Month - 2 =
VAR LastDateWithValues =
    CALCULATE ( MAX ( Sales[Date] ), REMOVEFILTERS () )
VAR RefDate =
    EOMONTH ( LastDateWithValues, -2 )
VAR DatesToUse =
    DATESINPERIOD ( 'Date'[Date], RefDate, -12, MONTH )
VAR Result =
    CALCULATE ( SELECTEDMEASURE (), DatesToUse )
RETURN
    Result

The key is to take the MAX of your fact table date column, not of 'Date'[Date].

You could also create a measure for the month name labels like

Label =
FORMAT ( MAX ( 'Date'[Date] ), "mmmm" )

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.