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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
JimmyKhan2022
Frequent Visitor

Ignore Page Level Filter on a Power BI Calculation Group

I have a Financial Year filter that does not select before 2021 . This is because there is PAGE level Filter that only allows the last 2 years , so only 2021 to 2023 .

Problem is that I have a 14 w Rolling Average, that when the 1st week in 2021 is selected, it does not work .

Code for measure 

    CALCULATE (
            DISTINCTCOUNT ( Sales[activity_id] ), 
            FILTER (
                Sales,
                Sales[done] = "Yes"
                    && Sales[activity_type]
                    IN { "In-Person Meeting", "Virtual Meeting", "Site Visit" }
            ) )


    Code for Caluclation group 
            VAR __lastVisibleDate =
            LASTDATE ( 'Calendar'[Date] )
        VAR _fromDate =
            CALCULATE ( DATEADD ( __lastVisibleDate, -91, DAY ), ALL ( 'Time') )
        VAR __result =
           CALCULATE (
               SELECTEDMEASURE (),
             REMOVEFILTERS ( 'Calendar' ), 
          
               'Calendar'[Date] > _fromDate
                    && 'Calendar'[Date] <= __lastVisibleDate
            ) 
            
        VAR _result_divide =
            DIVIDE ( __result, 13, 0 )
        RETURN
        
        
            IF ( _result_divide < 0.1, BLANK (), _result_divide )

I have tried every combination of ALL('Calendar' ) to get the rolling 14 week average to work for the 1st week of Jan 2021 . Debugging the _fromDate does give me the 20/10/2020 but the rolling average still does not work out correctly ! Argghhh !

Any ideas ? This is proving quite diffcicult

The PAGE level filter is needed to allow the user to select the financial year .

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@JimmyKhan2022 , If you do not want more week then selected then you can get avg with help date/calendar table

 

14 Month Avg = CALCULATE(AverageX(Values('Date'[MONTH Year]),calculate(Sum('Table'[Value)))
,DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-14,MONTH))

 

Or window function

 

Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@JimmyKhan2022 , If you do not want more week then selected then you can get avg with help date/calendar table

 

14 Month Avg = CALCULATE(AverageX(Values('Date'[MONTH Year]),calculate(Sum('Table'[Value)))
,DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-14,MONTH))

 

Or window function

 

Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

Top Kudoed Authors