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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
yugofukuda
Helper IV
Helper IV

12 month average on the same day

Hi,

 

For calculating a forecast, I would like to create the average of % on the same working day of last 12 months.

I would be appreciated if you could help me. Thanks!!

Sample99.png

1 ACCEPTED SOLUTION

Please try this one instead.  I didn't notice before that you have the Month column in the visual (not dates).

 

Collection % Last 12 Months =
VAR thisdate =
MAX ( 'Calendar'[Date] )
VAR last12months =
CALCULATETABLE (
VALUES ( 'Calendar'[Month] ),
ALL ( 'Calendar' ),
'Calendar'[Date] <= EOMONTH ( thisdate, 0 ),
'Calendar'[Date] >= EOMONTH ( thisdate, -11 )
)
RETURN
AVERAGEX ( last12months, [Collection %] )
 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

11 REPLIES 11
mahoneypat
Employee
Employee

Please try this expression

 

Avg Same WD =
VAR thisWD =
    MIN ( 'Date'[WD 22] )
VAR thisdate =
    MIN ( 'Date'[Date] )
RETURN
    AVERAGEX (
        FILTER (
            ALL ( 'Date'[Date] ),
            'Date'[Date] <= EOMONTH ( thisdate, 0 )
                && 'Date'[Date] >= EOMONTH ( thisdate, -12 )
                && 'Date'[WD 22] = thisWD
        ),
        [Percent Measure]
    )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@mahoneypat 

Thank you for your quick response!!

I don´t know why but i can´t put "Calendar WD22" in the part below. How should I do??

 

Avg Same WD =
VAR thisWD =
MIN ('Calendar'[WD 22])
VAR thisdate =
MIN ( 'Calendar'[Date] )
RETURN
AVERAGEX (
FILTER (
ALL ( 'Calendar'[Date]),
'Calendar'[Date] <= EOMONTH ( thisdate, 0 )
&& 'Calendar'[Date] >= EOMONTH ( thisdate, -12 )
&& 'Date'[WD 22] = thisWD
),
'Daily Collection'[Collection %]
)
 

Sample2020.png

My bad.  Forgot about that column.  Try this version.

 

Avg Same WD =
VAR thisWD =
MIN ('Calendar'[WD 22])
VAR thisdate =
MIN ( 'Calendar'[Date] )
RETURN
AVERAGEX (
FILTER (
ALL ( 'Calendar'[Date], 'Calendar'[WD 22]),
'Calendar'[Date] <= EOMONTH ( thisdate, 0 )
&& 'Calendar'[Date] >= EOMONTH ( thisdate, -12 )
&& 'Date'[WD 22] = thisWD
),
'Daily Collection'[Collection %]
)
 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@mahoneypat 
Thank you very much but It seems to me that it don´t work well.  There are something that I should change??

 

Sample1111.png

 

Please share the Collection % measure.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@mahoneypat 

Collection % = 'Daily Collection'[Collection for forecast]/calculate(sum(collection),all('Calendar'[WD 22]))
Collection for forecast = TOTALMTD(sum(collection),'Calendar'[Date])
 
Regards,

Signing off the the night.  Will take a look again tomorrow, if someone else doesn't solve it first.

 

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@mahoneypat  Thank you very much for your help!!

Please try this one instead.  I didn't notice before that you have the Month column in the visual (not dates).

 

Collection % Last 12 Months =
VAR thisdate =
MAX ( 'Calendar'[Date] )
VAR last12months =
CALCULATETABLE (
VALUES ( 'Calendar'[Month] ),
ALL ( 'Calendar' ),
'Calendar'[Date] <= EOMONTH ( thisdate, 0 ),
'Calendar'[Date] >= EOMONTH ( thisdate, -11 )
)
RETURN
AVERAGEX ( last12months, [Collection %] )
 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@mahoneypat 

Thank you very much!! It woked well!! you are so smart.

 

Sorry, could you do me a favor?? (other matter)

For calculating forecast, I created the expression as below but I don't know how to insert today´s WD22 automatically (for example, today´s wd22 is 17.  I tried to use calculate or lookupvalue but it didn´t work well.
Could you help me??
 

For Forecast =
CALCULATE('Daily Collection'[Collection % Last 12 Months],
'Calendar'[WD 22]=17  *I would like to put 17 automatically. 
,'Calendar'[Month]=format( DATE(YEAR(TODAY()),MONTH(TODAY())-1,DAY(TODAY())),"YYYY-MM"))


sample1010101.png

 

 

 

Greg_Deckler
Super User
Super User

@yugofukuda - You can create this column:

IsWorkingDay = IF(WEEKDAY([Date],2) < 6,1,0)

And then this column will return the working day number of every day in each month:

WorkingDay# = 
    VAR __WorkingDay = COUNTROWS(FILTER('Calendar',YEAR([Date])=YEAR(EARLIER([Date])) && MONTH([Date])=MONTH(EARLIER([Date])) && [Date]<=EARLIER([Date]) && [IsWorkingDay]=1))
RETURN
    IF([IsWorkingDay]=0,0,__WorkingDay)

PBIX is attached below sig.


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...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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