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
hcze
Helper II
Helper II

Total of calculated measure

Hi,

 

I have a Profit measure to calculate the difference between Revenue and Expense.

 

The DAX is 

Amount2 = If(MIN(Account[Account]) = "Profit",CALCULATE(SUM('Transaction'[Amount]),ALLSELECTED('Transaction')),SUM('Transaction'[Amount]))
 
I would like to include the Profit into total. The total should show 0 for control check but I am unable to achieve that. This is what I have so far.
 
2020-10-19_9-38-42.jpg
 
Thanks for helping.
 
AccountIndex
Revenue1
Expense2
Profit3
 
 
AccountAmount
Revenue-200
Expense100
1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @hcze,

You can use lookupvalue function to simple get the result based on the current account:

Measure =
LOOKUPVALUE (
    Transaction[Amount],
    Account[Account], SELECTEDVALUE ( Transaction[Account] ),
    SUM ( Account[Amount] )
)

Regards,

Xiaoxin Sheng

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

HI @hcze,

You can use lookupvalue function to simple get the result based on the current account:

Measure =
LOOKUPVALUE (
    Transaction[Amount],
    Account[Account], SELECTEDVALUE ( Transaction[Account] ),
    SUM ( Account[Amount] )
)

Regards,

Xiaoxin Sheng

amitchandak
Super User
Super User

@hcze , if you have table like the last one(Table2), Then better create a table like this and join with account table

 

Union( Table2,
summarize(Table2, "Account", "Profit", "Amount", sum(Table2[Amount])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
samdthompson
Memorable Member
Memorable Member

hello, perhaps something like :

 

Amount2

 

VAR transaction=SUM('Transaction'[Amount])

VAR Revenue=calculate(transaction,filter(account,[account]="revenue"))

VAR Expense=calculate(transaction,filter(account,[account]="expense"))

VAR Profit=Revenue+Expense

 

RETURN
=IF(HASONEVALUE(account[account]),transaction,Revenue+Expense-Profit)

 

 

I am on a mobile so cant error check this but think it will work. you might need to alter a couple of the table names to better suit your situation.

 

 

// if this is a solution please mark as such. Kudos always appreciated.

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.