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

I have a requirement to get 5 year average for revenue.

I have a table <Sales> with fields revenue, invoice date, year, month. I have to map a line chart with X as month, Y as revenue and filter is current year . So i need to map 5 year average of revenue for each of the month in 2020. Can you please share a way to do that

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

I think you want to show the five-year average of the month on the line chart. If my understanding is right, here’s my idea.

 

1. The source data is as below.

source.png

 

2. Create a calendar table.

Date =
VAR _calendar =
    CALENDAR ( MIN ( 'Sales'[invoice date] ), MAX ( 'Sales'[invoice date] ) )
RETURN
ADDCOLUMNS ( _calendar, "Year", YEAR ( [Date] ), "Month", MONTH ( [Date] ) )

calendartable.png

 

3. Write a measure to calculate the average.

ave = 
VAR t =
    SELECTEDVALUE ( 'Date'[Year] )
RETURN
    CALCULATE (
        DIVIDE ( SUM ( Sales[revenue] ), 5 ),
        FILTER ( ALL ( 'Date' ), 'Date'[Year] <= t && 'Date'[Year] >= t - 4 )
    )

 

4. After the measure is created, you can create the line chart and open Single select in Format.

line.png

line2.png

You can check more details from here.

 

 

Best Regards,

Icey

 

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

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Share some data and show the expected result in a simple Table format.  Once we compute the figures correctly, we can build any chart we want.  It will be best, if you can share an MS Excel workbook with your formulas there so that your calculation logic can be easily understood.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Icey
Community Support
Community Support

Hi @Anonymous ,

 

I think you want to show the five-year average of the month on the line chart. If my understanding is right, here’s my idea.

 

1. The source data is as below.

source.png

 

2. Create a calendar table.

Date =
VAR _calendar =
    CALENDAR ( MIN ( 'Sales'[invoice date] ), MAX ( 'Sales'[invoice date] ) )
RETURN
ADDCOLUMNS ( _calendar, "Year", YEAR ( [Date] ), "Month", MONTH ( [Date] ) )

calendartable.png

 

3. Write a measure to calculate the average.

ave = 
VAR t =
    SELECTEDVALUE ( 'Date'[Year] )
RETURN
    CALCULATE (
        DIVIDE ( SUM ( Sales[revenue] ), 5 ),
        FILTER ( ALL ( 'Date' ), 'Date'[Year] <= t && 'Date'[Year] >= t - 4 )
    )

 

4. After the measure is created, you can create the line chart and open Single select in Format.

line.png

line2.png

You can check more details from here.

 

 

Best Regards,

Icey

 

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

amitchandak
Super User
Super User

@Anonymous , for this year vs last year with help from date table

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
This year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
//Only year vs Year, not a level below

This Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

 

for rolling

Rolling 60 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],ENDOFMONTH(Sales[Sales Date]),-60,MONTH))
Rolling 60 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX(Sales[Sales Date]),-60,MONTH))

 

You can divide by 60 for Avg or use Average function in place of sum

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.