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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
brekeke
Frequent Visitor

Moving Average of Calculated Percentage Measure

Hi All,

 

I'm looking for a solution for the problem below.

 

Previously, @v-jiascu-msft had a good solution for quite the same challenge here but I realized that my question was a bit poorly articulated.

 

So here it is again, with a twist:

moving_avg_sample_v2.PNG

 

I'm looking for the moving average of the highlighted facts. The problem is that I need to derive the moving average from percentages.

 

Please find the sample file at this link: https://www.dropbox.com/s/tntayh3i1w0d3jy/moving_average_dummy_v0.2.pbix?dl=0

And data at this one: https://www.dropbox.com/s/0y7ms7zap07gash/moving_average_dummy.xlsm?dl=0

 

Thanks,

breki

 

1 ACCEPTED SOLUTION

@brekeke

 

This MEASURE hopefully will get you the desired results except for 2016_W03

 

 

Moving Average=
VAR Top3weeks =
    TOPN (
        3,
        CALCULATETABLE (
            VALUES ( tbl_periods_all[Period Column] ),
            FILTER (
                ALL ( tbl_periods_all ),
                tbl_periods_all[WeekNum] <= SELECTEDVALUE ( tbl_periods_all[WeekNum] )
                    && YEAR ( tbl_periods_all[Start Of Period] )
                        = YEAR ( SELECTEDVALUE ( tbl_periods_all[Start Of Period] ) )
            )
        ),
        CALCULATE ( SELECTEDVALUE ( tbl_periods_all[WeekNum] ) ), DESC
    )
RETURN
    IF (
        COUNTROWS ( Top3weeks ) = 3,
        AVERAGEX ( Top3weeks, [Cat_1 + Cat_2 % of Total] )
    )

Regards
Zubair

Please try my custom visuals

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

I would think that if you combine these two techniques:

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Rolling-Average/m-p/160720

 

https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149

 

That should get you there.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@brekeke

 

This MEASURE hopefully will get you the desired results except for 2016_W03

 

 

Moving Average=
VAR Top3weeks =
    TOPN (
        3,
        CALCULATETABLE (
            VALUES ( tbl_periods_all[Period Column] ),
            FILTER (
                ALL ( tbl_periods_all ),
                tbl_periods_all[WeekNum] <= SELECTEDVALUE ( tbl_periods_all[WeekNum] )
                    && YEAR ( tbl_periods_all[Start Of Period] )
                        = YEAR ( SELECTEDVALUE ( tbl_periods_all[Start Of Period] ) )
            )
        ),
        CALCULATE ( SELECTEDVALUE ( tbl_periods_all[WeekNum] ) ), DESC
    )
RETURN
    IF (
        COUNTROWS ( Top3weeks ) = 3,
        AVERAGEX ( Top3weeks, [Cat_1 + Cat_2 % of Total] )
    )

Regards
Zubair

Please try my custom visuals

@Zubair_Muhammad, this looks good and worked as well with some modifications. Thank you!

@brekeke

 

1092.png


Regards
Zubair

Please try my custom visuals

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.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.