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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pruthive
Regular Visitor

DAX Sum or Max value greater than input value(slicer)

Hi,

I have table columns sublock,elementpath, value(integer). sublock and elementpath forms unique key.

i have input slicer to enter scalar value integer value like 10, 44.input slicer sublock has values 1a,1b,1c to 1s, 2a,2b,2c to 2s, 4a,4b,4c to 4s

i created running total measure (RT_M)for input column value.

if user selects sublock slicer 4F. then report visual starts from 4F.i created distance measure from input slicer it will generate distance values(ex: 4f 0, 4g 1,4h 2) so i can sort visual by distance.If user enters 50 as input,i need to get max running total or sum up to the block. example in below screen shot for input 50 , running total greater than or equal to input value(50) reaches at block 4H.

 

I need to get sum value up to block 4H(from 4F to 4H) that is 54.47. I created measure that is working correct 80 percent of time , somet times its giving incorrect value. please help. thanks for ur time.

Below is the measure.

 

EndingMW_M =
var CurrDistance = [TargetMW_Dis]

var result = Calculate(SUM('EEP vwMWValue'[Value]),Filter(ALL('EEP vwMWValue'),'EEP vwMWValue'[D_I_M] >=0 &&'EEP vwMWValue'[D_I_M]<= CurrDistance))
RETURN
result

 

in above  [TargetMW_Dis] is measure max distance from block 4F to 4 H that is 2.

D_I_M is measure to calculate distance from slicer selection block(4F)

 

pruthive_2-1683781925372.png

pruthive_3-1683781945663.png

 

pruthive_4-1683782213632.png

4 REPLIES 4
Greg_Deckler
Super User
Super User

@pruthive Responding to your PM. You could try this version of your measure below. This would at least allow you to troubleshoot using TOCSV(__Table) in your return so that you could see what is and is not being returned by the FILTER statement. Otherwise, difficult to know what exactly the problem is without sample data, measure formulas and such.

EndingMW_M =
var CurrDistance = [TargetMW_Dis]
var __Table = Filter(ALL('EEP vwMWValue'),'EEP vwMWValue'[D_I_M] >=0 &&'EEP vwMWValue'[D_I_M]<= CurrDistance)
var result = SUMX( __Table, [Value])
RETURN
result

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
wdx223_Daniel
Super User
Super User

EndingMW_M =
var CurrDistance = [TargetMW_Dis]

 

var result = Calculate(SUM('EEP vwMWValue'[Value]),'EEP vwMWValue'[D_I_M] >=0 &&'EEP vwMWValue'[D_I_M]<= CurrDistance)
RETURN
result

throwing below error.thanks for ur time

pruthive_0-1683796821931.png

 

i tried below also. its giving incorrect result.

EndingMW_M =
var CurrDistance = [TargetMW_Dis]
var result = Calculate(SUM('EEP vwMWValue'[Value]),Filter('EEP vwMWValue','EEP vwMWValue'[D_I_M] >=0 &&'EEP vwMWValue'[D_I_M]<= CurrDistance))
RETURN
result

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors