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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
rhaddad87
Helper I
Helper I

Expression for SUM total to a max date in a table (that updates daily)

Hello,

I currently use this formula to determine the number of PoP Hours depending on the date selected.  I have to go in and change the date on the slider on a daily basis for it to update to today's information.

 

 

 

PoP Hours = SUM(dimSites[Daily Max Hours])*COUNTROWS(dimDate)

 

 

 

I'd like to produce a formula that will only count the number of rows from dimDate to the MAX date in 'xxData'[Date] so that I don't have to change the date everyday in the slider, I can leave it on a future date and the formula will auto update depending on the latest date in 'xxData'.  I can not count the rows in 'xxData'[DATE] because there are multiple entries per day

 

Thank you! 

1 ACCEPTED SOLUTION
bcdobbs
Community Champion
Community Champion

Direct replacement of what you have is

PoP Hours = 

VAR LatestDate = MAX('xxData'[Date])

VAR NumberOfDates = 
	CALCULATE(
		COUNTROWS(dimDate),
		dimDate[Date] < LatestDate
		)

RETURN
SUM(dimSites[Daily Max Hours])*NumberOfDates

 

However do you really want a count of dates in date table or are you really interested in just dates that exist in xxData in which case:

PoP Hours = 

VAR DatesInTable = 
	VALUES ( 'xxData'[Date] )

VAR NumberOfDates = 
	COUNTROWS ( DatesInTable )

RETURN
	SUM(dimSites[Daily Max Hours])*NumberOfDates


Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

2 REPLIES 2
bcdobbs
Community Champion
Community Champion

Direct replacement of what you have is

PoP Hours = 

VAR LatestDate = MAX('xxData'[Date])

VAR NumberOfDates = 
	CALCULATE(
		COUNTROWS(dimDate),
		dimDate[Date] < LatestDate
		)

RETURN
SUM(dimSites[Daily Max Hours])*NumberOfDates

 

However do you really want a count of dates in date table or are you really interested in just dates that exist in xxData in which case:

PoP Hours = 

VAR DatesInTable = 
	VALUES ( 'xxData'[Date] )

VAR NumberOfDates = 
	COUNTROWS ( DatesInTable )

RETURN
	SUM(dimSites[Daily Max Hours])*NumberOfDates


Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

oh wow, not only did you fix my problem with my solution, you showed me the benefit of using the correct function, VALUES.  Thank you so much!!!  This is so helpful! 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.