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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
labontee
Frequent Visitor

Stuck on matrix formatting and calculations

Hi,

Looking to format a single row, circled in red, and its values in a matrix and create a measure that SUMs a column based on a specific text and subtracts it from another SUM of the same column based on a different text. 

 

i.e. If the text is Revenue, SUM it and if the text is Expense, SUM it and then subtract Expenses SUM - Revenue SUM. I'd also like to add it a starting value so I can track balance over time (years). For example, I'd like to have the previous year's balance add to the next year's starting point and then do the  If the text is Revenue, SUM it and if the text is Expense, SUM it and then subtract Expenses SUM - Revenue SUM to provide the ending fund balance for that year. My starting year would just be a reference to a fixed amount.

 

labontee_1-1715021587227.png

 

 

4 REPLIES 4
Anonymous
Not applicable

Hi  @labontee ,

I created some data:

vyangliumsft_0-1715063167366.png

 

Here are the steps you can follow:

1. Create measure.

Measure =
IF(
    MAX('Table'[Type])="Revenue",SUMX('Table',[Value]),
IF(
    MAX('Table'[Type])="Expense"&&ISFILTERED('Table'[Group])=FALSE(),
    SUMX('Table',[Value])
    -
    SUMX(FILTER(ALL('Table'),'Table'[Type]="Revenue"&&'Table'[Year]=MAX('Table'[Year])),[Value])
    ,SUM('Table'[Value])))

2. Result:

It's not very clear how the "track balance over time (years)" works, could you express the expected results as a picture?

vyangliumsft_1-1715063167368.png

 

Best Regards,

Liu Yang

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

Thanks for putting all of this toegether. I've included a photo of the table I have in Excel that I'd like to replicate in Power BI. Each year's beginning fund blanace is the previous year's ending fund balance. The ending fund balance is the differenece of reveneues and expenses (sources and uses below). I also need to add in a beginning fund balance to start the whole data set off for FY 2016.

labontee_0-1715112412197.png

 

ExcelMonke
Super User
Super User

Consider the following:

Your Measure = 
VAR _Revenue = Your Revenue Calculation
VAR _Expense = Your Expense Calculation

RETURN
IF(Table[Type]="Revenue",_Revenue,_Expense)




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

Proud to be a Super User!





Not exaclty what I was thinking but it did lead me down a rabbit hole of understanding variables. I was able to take this and learn how to subtract expenses from revenue for a given year.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors