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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
jhilsee
New Member

Help with Matrix

I am new to Power BI and have a basic understanding of how to use it.  I am trying to calculate the variance between 2024 and 2025 in my matrix visiual. My data is set up with a column for the year.  

jhilsee_0-1738256199122.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the reply from Gabry.

 

Hi @jhilsee ,

 

I used sample data, here are the exact steps:

1. Create a date table:

vlinhuizhmsft_0-1738572658372.png

 

2. Create a relationship as shown:

vlinhuizhmsft_1-1738572715804.png

 

3. Create a measure:

Profit Difference = 
VAR _minyear=MINX(ALLSELECTED('Date'[Year]),'Date'[Year])
VAR _maxyear=MAXX(ALLSELECTED('Date'[Year]),'Date'[Year])
return
CALCULATE(SUM('financials'[Profit]),'Date'[Year]=_maxyear)-CALCULATE(SUM('financials'[Profit]),'Date'[Year]=_minyear)

 

4. Create a slicer using the Year field from the Date table and replace the Year column in the matrix with the Year field from the Date table. Result:

vlinhuizhmsft_2-1738573008042.png

Best Regards,
Zhu

 

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thanks for the reply from Gabry.

 

Hi @jhilsee ,

 

I used sample data, here are the exact steps:

1. Create a date table:

vlinhuizhmsft_0-1738572658372.png

 

2. Create a relationship as shown:

vlinhuizhmsft_1-1738572715804.png

 

3. Create a measure:

Profit Difference = 
VAR _minyear=MINX(ALLSELECTED('Date'[Year]),'Date'[Year])
VAR _maxyear=MAXX(ALLSELECTED('Date'[Year]),'Date'[Year])
return
CALCULATE(SUM('financials'[Profit]),'Date'[Year]=_maxyear)-CALCULATE(SUM('financials'[Profit]),'Date'[Year]=_minyear)

 

4. Create a slicer using the Year field from the Date table and replace the Year column in the matrix with the Year field from the Date table. Result:

vlinhuizhmsft_2-1738573008042.png

Best Regards,
Zhu

 

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

Gabry
Super User
Super User

Hello @jhilsee ,

It depends on how you want to display it.

The first thing you should do is create a date table.

You can create a date table with the following:

Dates= calendarauto()

However, I recommend learning more about this, as a date table is very important.

 

Then you need to set a relationship between the date from dates table and the date of Combined table.

Then, you can create a measure like this:

 

Variance CY vs PY= sum('COmbined'[amount])- calculate(sum('COmbined'[amount]), sameperiodlastyear('Dates'[date])

This formula calculates the amount for the current year, based on the filter context, and subtracts the amount from the previous year.

Thank you!  I will give this a try.

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.