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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Sum of expense is wrong when multiple date selected

this is my pbix file : https://1drv.ms/u/s!Ag9tIyk2ofNRjk7ex9NVCSWmzVF9?e=hzuIkt


i have this measure:

 

Expenses = 
var NEWtotalrevenue = CALCULATE(SUM(Revenue[Total]),FILTER('Calendar','Calendar'[Date] >= DATE(2022,10,3)))
VAR OLDtotalrevenue = CALCULATE(SUMX(Revenue,Revenue[Amount]*Revenue[Qtty]),FILTER('Calendar','Calendar'[Date] < DATE(2022,10,3)))
VAR totalrevenue = OLDtotalrevenue + NEWtotalrevenue
Var newsalesmanrevenue = CALCULATE(SUM(Revenue[Total]),FILTER('Calendar','Calendar'[Date] >= DATE(2022,10,3)),Revenue[Salesman]="A")
VAR Oldsalesmanrevenue = CALCULATE(SUMX(Revenue,Revenue[Amount]*Revenue[Qtty]),FILTER('Calendar','Calendar'[Date] < DATE(2022,10,3)),Revenue[Salesman]="A")
VAR salesmanrevenue = Oldsalesmanrevenue + newsalesmanrevenue
VAR percentage = salesmanrevenue/totalrevenue
var expenses = SUM(Expense[Total])
return
expenses*percentage

 




those are the pictures:
expense table:

expense table.png

 

revenue table:

Screenshot 2022-10-14 153511.png

 

week 40  :

week40.png


 week 41:

week41.png

both selected weeks:

both weeks.png

as you see expense on both selected dates is 801.01 
but if you manually add week 40 and week 41,
i get 365.30 + 431.27 = 796.57 
any help is appreciated

@Jihwan_Kim 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood the question correctly, but please try the below measure whether it suits your requirement.

 

Expenses V2 =
VAR _newtable =
    ADDCOLUMNS (
        DISTINCT ( 'Calendar'[Week of Year] ),
        "@percentage", [Percentage V2],
        "@expensetotal", CALCULATE ( SUM ( Expense[Total] ) )
    )
RETURN
    SUMX ( _newtable, [@percentage] * [@expensetotal] )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood the question correctly, but please try the below measure whether it suits your requirement.

 

Expenses V2 =
VAR _newtable =
    ADDCOLUMNS (
        DISTINCT ( 'Calendar'[Week of Year] ),
        "@percentage", [Percentage V2],
        "@expensetotal", CALCULATE ( SUM ( Expense[Total] ) )
    )
RETURN
    SUMX ( _newtable, [@percentage] * [@expensetotal] )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Youre a life saver thank you

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.