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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

How to do row over row calculation in Power BI matrix?

Hi,

 

I used the import query to load daily attendance into the Power BI. The raw data is shown in picture 1.

 

Picture 1Picture 1 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Then I counted the attendance number in different categories by matrics. As you can see from picture 2, the "Exhibit Attendance" column is the detailed categories of attendance. The rest of the columns are made by different measures, eg. the measure caculated the attendance number of month to date last year is [ Month to Date LY] = CALCULATE([Total Attendance],DATESBETWEEN('Dates'[Date],DATE(YEAR(MAX('Dates'[Date]))-1, 

MONTH(MAX('Dates'[Date])), 1),DATE(YEAR(MAX('Dates'[Date]))-1, 
MONTH(MAX('Dates'[Date])), DAY(MAX('Dates'[Date])))))Picture 2Picture 2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

In EXCEL, if I want to get the number of attendance (excluding school groups), I can do the row over row calculation easily by row 15-row13, and get the highlighted row in picture 3.Picture 3Picture 3

 

 

 

 

 

 

 

 

 

 

 

So how can I achieve the same result in Power BI matrix?

 

Thanks,

Selene 

3 REPLIES 3
Anonymous
Not applicable

I think what you want and what you are asking for are actually different things.

 

What you want is a total, which excludes certain data based on a condition.  I'd recommend a measure to do this.  This will be in the form of a CALCULATE statement, using your original methodology, and applying a filter of "Exhibit attendance <> "School Group Visits"

 

This could also be done in its own visual by the advanced filtering section.

 

Anonymous
Not applicable

Hi Ross,

 

Thanks very much for your response. I think the case I shared is a bad one. What if I need to calcluate the percentage of one row over another row?

 

Picture 4 is one example that equals = row 22/row 15.Picture 4Picture 4

 

 

 

 

 

 

 

 

 

 

 

 

Thanks!

 

Selene

Anonymous
Not applicable

You could create a measure specifically designed to only return data for a specific scenario, such as "School Group Visits".  You can create a 3rd measure that does a calculation using the other two.

 

So as an example you could use the Calculate with Filter statement to create measure1 and measure2.  Measure3 could be something like  DIVIDE(Measure1, Measure2).  Then whenever you use measure 3, measure 1 and measure 2 will have the context needed to make the calculation work.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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