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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. 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
Solution Specialist
Solution Specialist

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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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