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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Abhaykumar
Microsoft Employee
Microsoft Employee

Getting average of a measure and plotting as a trend line

I have a measure as following: 

 

Normalized Events = (IF ((COUNTROWS(FILTER('Events',[Type]="TypeA")) = 0), 0,COUNTROWS(FILTER('Events',[Type]="TypeA"))))/ COUNTROWS(FILTER('Population',[Type]="TypeA"))

 

This is plotted on a line chart with dates as x-axis. I also want to show a mean value as another line on the chart. How can i get the average of this measure as a single value that can be plotted as a horizontal line?

4 REPLIES 4
CheenuSing
Community Champion
Community Champion

@Abhaykumar

 

1. I created a scenario where in I have the sales data by date and there are more than 1 sales record for a day. This is called BaseSales

    

DateSales
2016030120
2016030130
2016030150
2016030425
2016030445
2016030440
2016030935
2016030955
2016040415
2016040434
2016040490
2016040445
2016040475
2016040440
20160420120
20160420130

 

2. The first step  is to get the averages by day and store it as a table created dynamically. 

3. To do this selecte new table from modelling and enter the code as follows

    AverageByDay(TableName) = Summarize( BaseSales, BaseSales[Date], "ByDayAverage",Average(BaseSales[Sales]))

4. What this actually does is creates an average by day from the base sales data and stores in the column ByDayAverage and stores the entire rows as table AverageByDay.

5. Create a mesaure AvgofAvg =Calculate(Average([ByDayAverage]),AllSelected(AverageByDay[Date]))

6. From this new table AverageByDay create the combo chart with Date as Shared Axis, ByDayAverage as ColumnValues and AvgofAvg as LineValues.

7. The chart will be the way you wanted.

 

Try it out and if you have any problems do reply to the post. Send me your mail id so that I can send you the pbix file.

 

If you find the solution working , please accept it as a solution and also give Kudos.

 

Cheers

 

 

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!
v-caliao-msft
Microsoft Employee
Microsoft Employee

@Abhaykumar, You can add a calculated column using the same DAX expression , and then add this new column to Values.

Capture1.PNG
Capture.PNG

 

Regards,

Charlie Liao

@v-caliao-msft, I did the same thing but the average does not seem to be correct. As from the following screenshot, the average is 0.18 but when the column is plotted it shows average to be 0.20. I also added a second column with following DAX : 

AvgCol = AVERAGE(Event41[TestCol]). But this gives the same result of 0.20. Interestingly median also gives the same results.

 

2016-06-28 17_11_27-Img3.jpg

Anonymous
Not applicable

A bit of a guess here, but this sounds reasonable to me:

 

Median Event := MEDIANX(Calendar, [Normalized Events])

 

just drop this measure on your on your chart... maybe? 🙂

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.