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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Dynamic Average (calendar year to date)

Hi experts! 🙂

 

I am trying to create a dynamic average of the sales based on the current year sales (calendar year to date)
so it would be the average sales from jan'2020 until july'2020

and then when I ad August, it would add up August and calculate the new average based on the 8 months from the year
What formula should I use? I tried using Averagex, but I think I missed something.

 

thanks for the help

1 ACCEPTED SOLUTION

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

 

Table:

c1.png

 

You may create  calculated columns and a measure as below to get the average of Sales from January2020 until the latest month(August) that year.
Calculated column:

Year = YEAR('Table'[Date])

Month = MONTH('Table'[Date])

YearMonth = YEAR('Table'[Date])*100+MONTH('Table'[Date])

 

Measure:

Avg = 
DIVIDE(
    CALCULATE(
        SUM('Table'[Sell Out(MSU)]),
        FILTER(
            ALL('Table'),
            [Year]=YEAR(TODAY())&&
            [Month]>=1&&
            [Month]<=MONTH(TODAY())
        )
    ),
    CALCULATE(
        DISTINCTCOUNT('Table'[YearMonth]),
        FILTER(
            ALL('Table'),
            [Year]=YEAR(TODAY())&&
            [Month]>=1&&
            [Month]<=MONTH(TODAY())
        )
    )
)

 

Result:

c2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

If you take the answer of someone, please mark it as the solution to help the other members who have same problems find it more quickly. If not, let me know and I'll try to help you further. Thanks.

 

Best Regards

Allan

 

mhossain
Solution Sage
Solution Sage

Hi @Anonymous 

 

Can you try this ----- YTD Avg = CALCULATE(AVERAGE(Table[Value]), DATESYTD(Table[Date], "mention the date here"))

In order to make YTD dynamic at the place of "mention the date here" you can use some time intelligence table probably.

Anonymous
Not applicable

it didnt work 😞
@mhossain 

yohandipt_0-1596761908282.png

this is my table set, I am trying to get the average of Sales from January2020 until the latest month that year.

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

 

Table:

c1.png

 

You may create  calculated columns and a measure as below to get the average of Sales from January2020 until the latest month(August) that year.
Calculated column:

Year = YEAR('Table'[Date])

Month = MONTH('Table'[Date])

YearMonth = YEAR('Table'[Date])*100+MONTH('Table'[Date])

 

Measure:

Avg = 
DIVIDE(
    CALCULATE(
        SUM('Table'[Sell Out(MSU)]),
        FILTER(
            ALL('Table'),
            [Year]=YEAR(TODAY())&&
            [Month]>=1&&
            [Month]<=MONTH(TODAY())
        )
    ),
    CALCULATE(
        DISTINCTCOUNT('Table'[YearMonth]),
        FILTER(
            ALL('Table'),
            [Year]=YEAR(TODAY())&&
            [Month]>=1&&
            [Month]<=MONTH(TODAY())
        )
    )
)

 

Result:

c2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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