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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Laiq_Rahman
Helper I
Helper I

Running total on avg measure from the direct query

Hi,

 

I'm connecting to a big table using direct query. I've to create a average measure based on a table which is working perfect.

BID_VOL = 
var avg_bid_avail = CALCULATE(AVERAGE(dataSAMPLE[BID_AVAIL]), FILTER(dataSAMPLE, dataSAMPLE[BID_VOLUME] <> 0))
var AVG_BID_VOLUME = CALCULATE(AVERAGE(dataSAMPLE[BID_VOLUME]), FILTER(dataSAMPLE, dataSAMPLE[BID_VOLUME] <>0))
return IF(MAX(DATAAVAILABLE[dataavailable]) = "ALL", AVG_BID_VOLUME,         avg_bid_avail)

 

Then i've to create running total based on the outcome of this data. I created a measure for it.

BID_VOL running total in STATION_NAME = 
CALCULATE(
	[BID_VOL],
	FILTER(
		ALLSELECTED(dataSAMPLE[STATION_NAME]),
		ISONORAFTER(dataSAMPLE[STATION_NAME], MAX(dataSAMPLE[STATION_NAME]), DESC)
	)
)

 

I am getting the below output but this is not what i am expecting.

 

Laiq_Rahman_0-1712720831172.png

 

I want an output like below.

 

Laiq_Rahman_1-1712720940334.png

 

I've added a sample pbix file for your review. Can you please help what would be the dax for it?  

 

https://drive.google.com/file/d/1xYA-r3hxRrydQ_a_qc16NNnQWt_dpi-k/view?usp=sharing

 

Please note it's a direct query and connecting to big table. So, adding calculated column or adding index column in power query mayn't help.

 

Regards,

Laiq

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Laiq_Rahman 

 

Try the following code:

BID_VOL running total in STATION_NAME = SUMX(
		SUMMARIZE(
			FILTER(
				ALLSELECTED('dataSAMPLE'),
				'dataSAMPLE'[STATION_NAME] <= MAX('dataSAMPLE'[STATION_NAME])
			),
			'dataSAMPLE'[STATION_NAME],
			"D", [BID_VOL]
		),
		[D]
	)

 

MFelix_0-1712756064413.png

 

MFelix_1-1712756077785.png

File attached.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português





View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @Laiq_Rahman 

 

Try the following code:

BID_VOL running total in STATION_NAME = SUMX(
		SUMMARIZE(
			FILTER(
				ALLSELECTED('dataSAMPLE'),
				'dataSAMPLE'[STATION_NAME] <= MAX('dataSAMPLE'[STATION_NAME])
			),
			'dataSAMPLE'[STATION_NAME],
			"D", [BID_VOL]
		),
		[D]
	)

 

MFelix_0-1712756064413.png

 

MFelix_1-1712756077785.png

File attached.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português





Awesome. I've spent days to figure out. Problem solved now.... Thank you so much. 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.