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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Dan_W
Frequent Visitor

Sum based on filters

Hi,

 

I have data comprised of running totals that looks like below and I'm trying to find totals for the asset when filtering for asset and dates.

 

DATE	ASSET	QTY
1/1/18 12:00 AM	B	1
1/1/18 1:15 AM	A	8
1/1/18 5:17 AM	A	13
1/1/18 9:12 AM	B	18
1/1/18 12:43 PM	B	24
1/1/18 2:09 PM	A	31
1/1/18 2:19 PM	B	37
1/1/18 6:29 PM	B	42
1/1/18 7:12 PM	A	50
1/1/18 10:28 PM	A	51
1/2/18 12:22 AM	A	56

Since the quanties are running totals - I have used the MAX-MIN to find interval total when filtering over dates for a single asset, but I haven't been able to calculate a sum for both assets.  

 

With my  Measure ( Interval Total = [MaxValue] - [MinValue]) it is simly taking the MAX and MIN values so it will work with one "ASSET" selected, but not both.

image.png

 

How do I create a measure that will sum the "ASSET" categories so i will have a total of 5,000 in the calculation above?

 

I can share a file, but it is kind of difficult from my current location.

 

Thanks for any advice,

Dan

 

 

 

 

 

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

@Dan_W,

Please check if the following DAX returns your expected result. If not, please share source file via OneDrive.

Grand Total = var MaxValue = MAX(Sheet1[QTY])
var MinValue = MIN(Sheet1[QTY])
var Interval Total = MaxValue - MinValue

Return 

SUMX(
                   CALCULATETABLE(
                                  ALLSELECTED(Sheet1[ASSET])),
                                  Interval Total)



Regards,
Lydia

View solution in original post

Thank you Lydia -your suggestion worked perfectly.

View solution in original post

3 REPLIES 3
Dan_W
Frequent Visitor

I have gotten a little closer:

 

My inital measures were:

 

MaxValue = MAX(Sheet1[QTY])
MinValue = MIN(Sheet1[QTY])
Interval Total = [MaxValue] - [MinValue]

 

 

Giving me this:

image.png

I tried using SUMX to iterate a table like above - and can now get the totals (i'm not sure if that is exactly what is going on?)

 

Grand Total = SUMX(
                   CALCULATETABLE(
                                  ALLSELECTED(Sheet1[ASSET])),
                                  ([MaxValue]-[MinValue]))

 

image.png

 

Somehow I got where I intended - not really sure how, but is there a way to clean my "Grand Total" measure?

How can I get rid of the intermediary steps of having the MIN and MAX measures?

When I exchange the measures [Maxvalue]  for the underlying calculation MAX('sheet1[QTY]) - my results are incorrect?

 

Thanks

Anonymous
Not applicable

@Dan_W,

Please check if the following DAX returns your expected result. If not, please share source file via OneDrive.

Grand Total = var MaxValue = MAX(Sheet1[QTY])
var MinValue = MIN(Sheet1[QTY])
var Interval Total = MaxValue - MinValue

Return 

SUMX(
                   CALCULATETABLE(
                                  ALLSELECTED(Sheet1[ASSET])),
                                  Interval Total)



Regards,
Lydia

Thank you Lydia -your suggestion worked perfectly.

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.