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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
IP_Kornel
Frequent Visitor

SUM of MAX on certain day per GROUP

Hey,

I'm struggling to find myself any solution to this and everything that I've found here or in google doesn't quite replicate my need.

Example input date

IP_Kornel_0-1738929059472.png

What I'm trying to achieve is line chart over time that will show um of "current" budgets at a specific time.
For the data above it should look like this

IP_Kornel_1-1738929168916.png

IP_Kornel_0-1738929926310.png


I've tried something like this 

CALCULATE(SUM(TABLE_B[BUDGET]), FILTER(ALLSELECTED(TABLE_B), TABLE_B[DATE] <= MAX(CALENDAR[DATE])))
but this sums every version up to calendar date, not the "currently last". I have no clue how to filter it properly.

 

1 ACCEPTED SOLUTION

Thanks @danextian 
Your solutions wasn't quite what I expected but it gave me somewhat an idea what I should look for.
After a few hours I think I figured it out and numbers seem to add up correctly and below is my solution if anyone is looking for something similar

_BOT = 
VAR _BT = FILTER(ALLSELECTED('BUDGETS'), 'BUDGETS'[DATA] <= MAX(CALENDAR[DATA]))
VAR _BG = SUMMARIZE(_BT, [PROJECT NUMBER], "@VERSION", MAX('BUDGETS'[VERSION]))
VAR _BC = FILTER(NATURALLEFTOUTERJOIN(_BG, ALLSELECTED('BUDGETS')), [@VERSION] = 'BUDGETS'[VERSION])

RETURN
    SUMX(_BC, 'BUDGETS'[BUDGET])

 

View solution in original post

4 REPLIES 4
sevenhills
Super User
Super User

Try this?

 

RT 1 = IF ( SELECTEDVALUE('Date Table'[YYYYMM]) <= Format(EOMONTH(date(2025, 3, 1), 0), "yyyymm"), 
CALCULATE(
	SUM('Table'[BUDGET]),
	FILTER(
		ALLSELECTED('Date Table'[Date]),
		ISONORAFTER('Date Table'[Date], MAX('Date Table'[Date]), DESC)  
	)
), BLANK())
danextian
Super User
Super User

Hi @IP_Kornel 

 

Assuming that each group is a combination of project, version, and date from the same table, try this:

SUMX (
    SUMMARIZECOLUMNS (
        'table'[project],
        'table'[version],
        'table'[date],
        "@max budget", CALCULATE ( MAX ( 'table'[budget] ) )
    ),
    [@max budget]
)

The measure will create a virtual summary of the specified columns and calculate the maximum budget for each combination of those columns. Finally, the maximum values are summed up. Otherwise, please provide a workable sample data (not an image), your expected result from the same sample data and the reasoning behind.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thanks @danextian 
Your solutions wasn't quite what I expected but it gave me somewhat an idea what I should look for.
After a few hours I think I figured it out and numbers seem to add up correctly and below is my solution if anyone is looking for something similar

_BOT = 
VAR _BT = FILTER(ALLSELECTED('BUDGETS'), 'BUDGETS'[DATA] <= MAX(CALENDAR[DATA]))
VAR _BG = SUMMARIZE(_BT, [PROJECT NUMBER], "@VERSION", MAX('BUDGETS'[VERSION]))
VAR _BC = FILTER(NATURALLEFTOUTERJOIN(_BG, ALLSELECTED('BUDGETS')), [@VERSION] = 'BUDGETS'[VERSION])

RETURN
    SUMX(_BC, 'BUDGETS'[BUDGET])

 

Anonymous
Not applicable

Hi,@IP_Kornel 
We are delighted that you have found a solution and are willing to share it with everyone.

 

Accepting your post as the solution is very helpful to our community, as it allows members with similar issues to find answers more quickly.

 

Thank you for your valuable contribution to the community. If you encounter new problems in the future, feel free to ask questions in the forum again. Wishing you all the best!

 

Best Regards,

Leroy Lu

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

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.