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

Aggregate by months and calculate average

Hello,

i have a table like the following one:

REQUESTED_DATEVALUE
01.01.201810
......
28.01.20188


I want to show the following in a line diagram:

X-axis: fixed 12 months (january-december; business year)

First line:

VALUE summed for each month

Second line:

Avergage of VALUE last year as a straight line (but mapped/shown to the fixed X-axis)

 

How can i achieve this?

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Create a measure

average last year = CALCULATE(AVERAGE('Table 3'[value]),FILTER(ALLSELECTED('date'),DATEADD('date'[Date],-1,YEAR)))

Capture2.JPGCapture3.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
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
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Create a measure

average last year = CALCULATE(AVERAGE('Table 3'[value]),FILTER(ALLSELECTED('date'),DATEADD('date'[Date],-1,YEAR)))

Capture2.JPGCapture3.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
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 , Try with time intelligence

 

YTD Sales = CALCULATE([Avg Monthly],DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE([Avg Monthly],DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
This year Sales = CALCULATE([Avg Monthly], DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year Sales = CALCULATE([Avg Monthly],DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE([Avg Monthly],DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))

 

 

Refer Power BI — YTD Questions — Time Intelligence 1–5
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184


Appreciate your Kudos.

Anonymous
Not applicable

Thank you for your quick reply.

Could you also explain me how to achieve the aggregation by month?
I have lots of dates but don't know, how to aggregate them for a line chart.

This is my expected result:

MIuser1_0-1595331063657.png

 

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.