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
Kris48
Frequent Visitor

excluding the Date Flagged

I would like to add logic to exclude days that have the "T" flag on the calendar in measure: "Value_measure_1"

URL pbix: https://drive.google.com/file/d/1rTsECeGnNXDVG0TR-_tkpnNRZnQGRv9K/view?usp=sharing 

 

1.png2 (1).png

 

1 ACCEPTED SOLUTION

@Kris48 

 

yes you are right. update _Y variable as follows:

 

var _YDATESBETWEEN('Calendar'[Date]SELECTEDVALUE('Fact'[Data from]) , SELECTEDVALUE'Fact'[Data to]))
 
* I've updated my previous response to correct a part of the measure based on feedback. this will make it easier for others to find the right answer quickly. thanks for feedback

View solution in original post

3 REPLIES 3
Selva-Salimi
Super User
Super User

Hi @Kris48 

 

you should update your measure as follows:

 

Value_measure_1 =
var _Y= DATESBETWEEN('Calendar'[Date], SELECTEDVALUE('Fact'[Data from]), SELECTEDVALUE( 'Fact'[Data to]))
var _Tdates = summarize(FILTER('Calendar','Calendar'[Flag] in {"T"}),'Calendar'[Date])
var _X= FILTER(_Y , 'Calendar'[Date] in _Tdates)
VAR CurrentDate = TODAY()
VAR FilteredFact =
    FILTER(
        'Fact',
        'Fact'[Data from] > CurrentDate
    )
VAR LastRevValue =
    CALCULATE(
         LASTNONBLANKVALUE(Rev[Date] , SUM('Rev'[Value])), TREATAS(VALUES('Fact'[INDEX]) , Rev[INDEX])
    )
VAR DaysBetween =
    SUMX(
        FilteredFact,
        DATEDIFF('Fact'[Data from], 'Fact'[Data to], DAY)+1
    ) - COUNTROWS(_X)
RETURN
LastRevValue * DaysBetween
 
If this post helps, then I would appreciate a thumbs up 👍 and mark it as the solution to help the other members find it more quickly.

@Selva-Salimi 

Thank you, but unfortunately it doesn't work well. I took your variable into a separate measure and named the measure "_Tdates_X" .
Unfortunately, it wrongly counts the days that are supposed to have flag = "T"
PBIX: https://drive.google.com/file/d/1Zf_h6B2iYrYrfrnO9qJEmReXMk9cYPYb/view?usp=sharing 

1.png

@Kris48 

 

yes you are right. update _Y variable as follows:

 

var _YDATESBETWEEN('Calendar'[Date]SELECTEDVALUE('Fact'[Data from]) , SELECTEDVALUE'Fact'[Data to]))
 
* I've updated my previous response to correct a part of the measure based on feedback. this will make it easier for others to find the right answer quickly. thanks for feedback

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.