Forum Discussion

Kris48's avatar
Kris48
Frequent Visitor
1 year ago
Solved

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 

 

 

  • @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

3 Replies

  • 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's avatar
        Selva-Salimi
        Solution Sage

        @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