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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Tripb44
Helper II
Helper II

Filter context for measure



I have a measure that I need to add some logic to which would write: If a quote has an order date then return blank.  How would I add that extra logic in to my below measure?  Thanks. 
(1.2) =
var _date = SELECTEDVALUE('Date'[Date])
var _avgquote = AVERAGEX(Cycletime,Cycletime[quote_total])
return
IF(HASONEVALUE(Cycletime[QuoteNum]),
_avgquote,
SUMX(filter(Cycletime,Cycletime[EntryDate]>_date),_avgquote))

1 ACCEPTED SOLUTION

@Tripb44 

Not sure how your model and the visual are  setup, can you try the following:

m =
VAR _date =
    SELECTEDVALUE ( 'Date'[Date] )
VAR __t =  FILTER ( Cycletime , Cycletime[Order Date]  = BLANK () )    
    
VAR _avgquote =
    AVERAGEX ( __t, Cycletime[quote_total] )
RETURN
    IF (
        HASONEVALUE ( Cycletime[QuoteNum] ),
        _avgquote,
        SUMX ( FILTER ( __t, Cycletime[EntryDate] > _date ), _avgquote )
    )
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

3 REPLIES 3
Fowmy
Super User
Super User

@Tripb44 

Can you try this measure ?

Measure = 
var _date = SELECTEDVALUE('Date'[Date])
var _avgquote = AVERAGEX(Cycletime,Cycletime[quote_total])
return
IF(
    NOT(ISBLANK (Cycletime[order date]) ) &&HASONEVALUE(Cycletime[QuoteNum]),
    _avgquote,
    SUMX(filter(Cycletime,Cycletime[EntryDate]>_date),_avgquote)
)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

It is not allowing me to select OrderDate from the table for some reason? 

Tripb44_0-1635172160524.png

 

@Tripb44 

Not sure how your model and the visual are  setup, can you try the following:

m =
VAR _date =
    SELECTEDVALUE ( 'Date'[Date] )
VAR __t =  FILTER ( Cycletime , Cycletime[Order Date]  = BLANK () )    
    
VAR _avgquote =
    AVERAGEX ( __t, Cycletime[quote_total] )
RETURN
    IF (
        HASONEVALUE ( Cycletime[QuoteNum] ),
        _avgquote,
        SUMX ( FILTER ( __t, Cycletime[EntryDate] > _date ), _avgquote )
    )
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors