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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

wrong sum of expense when selecting multiple date

Hello everyone,

PBIX file : https://1drv.ms/u/s!Ag9tIyk2ofNRjlBFygNBL3s9VG2N?e=qoIeBc
Excel file: https://1drv.ms/x/s!Ag9tIyk2ofNRjk9-uND6F2ZLZgaZ?e=oAWQzt

I have revenue table which includes service name and all, and expense table which include service expense

to calculate percentage, i need to do servicerevnue / total_revenue
then service expense is calculated_percentage * total-service_expense



when i select for example october 4:

service1.png

 

and when i select october 5:

service2.png

 

and when i select both:

allservice.png

as you see, lets take service A:

on october 4, expense is 163.58 and gross is 1,041.42

on october 5, expense is 32.63 and gross is 376.47
so if i select october 4 and october 5 together:
i should get for expense = 196.21 and gross = 1417.99

 

but as photo above states, i got the numbers wrong

 

please help

1 ACCEPTED SOLUTION

@Anonymous 

I provided my explanation in my first reply. Attached the solution for the example yoy have provided in this post.

2.png

View solution in original post

11 REPLIES 11
tamerj1
Super User
Super User

Hi @Anonymous 
Please refer to attached sample file with the solution

1.png

Taxes = 
SUMX ( 
    VALUES ( 'Calendar'[Date] ),
    CALCULATE ( 
        SUM ( Expense_Table[Total] ) * MAX  ( New_Tax_Rate_Table[Percentage] )
    )
)
Anonymous
Not applicable

@tamerj1 why is it when i do the calculations seperatly it works but when i make them into one measure and use Var it doesnt give the same answer?

@Anonymous 
Please provide more context. Please provide one example.

Anonymous
Not applicable

@tamerj1  i already provided example and the powerbi file in the main topic

 

@Anonymous 

I provided my explanation in my first reply. Attached the solution for the example yoy have provided in this post.

2.png

Anonymous
Not applicable

@tamerj1 thank you very much i appreciate your help

for somereason it works on the sample data but i did the same exact calculation and method on my work project but doesnt work for some reason

@Anonymous 
Perhaps it has a different filter context. Maybe you can share more details to assist you further.

Anonymous
Not applicable

Thank you veey much but this is another post for taxes and this one is for the expense can you please help out

@Anonymous 

Sure. However, it is the same approach; you need to iterate over the the selected dates one by one, perform the calculation for each date then sum the individual results for all the selected dates. 
what is the formula for Expanses?

Anonymous
Not applicable

Anonymous
Not applicable

@tamerj1 it is included in the powerbi file but this is the formula

ServicerevenueA = CALCULATE(SUM(revenue_table[total]),revenu_table[service]= "Service A")

 

Total revenue = SUM(revenue_table[total])

 

PercentageA = [servicerevenueA]/[total revenue]

 

Service expense = CALCULATE(SUM(expense_table[total]),expense_table[eligible for service revenue] = "true")

 

ExpenseA = [PercentageA] * [serviceexpense]

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.

Top Solution Authors