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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
ghutchins
Helper II
Helper II

Aggregation Problem in a Line Graph

I need a line graph that visualizes the Average % by day based on rows of data. Location may report multiple times a day or skip days.

 

  • Counted is a total that met a condition out of a Population
  • DAX Calculated % is a measure that divides Counted by Population

DAX Calculated % = 1 -
DIVIDE(
SUM(Counted),
SUM(Population)
)

  • The line graph is set up as Axis = Date and Values = DAX Calculated %
  • Expect to see one data point...  Average %...  per day in the line graph

What is needed based on the tables below is a line graph with 2 data points, 4/1/2020 at 75.4% and 4/10/2020 at 83.4%. The problem that I cannot get around is the line graph is instead further aggregated by site. Based on the data below my line graph shows 5 data points for 4/1/2020 and 5 data points for 4/10/2020... one data point for each site for each day.

 

I fail to write the correct DAX to arrive at Average %.. Thanks for any help in advance.

 

Sample data from Data Source

LocationDateCountedPopulationDAX Calculated %
A4/1/202091090%
B4/1/20208.81088%
C4/1/20209.91099%
D4/1/20201010100%
A

4/1/2020

0100%
B4/10/20204.51045%
B4/10/20209.41094%
C4/10/20209.51095%
D4/10/20201001100%

 

Expected data the line graph would use to plot line, (Average % is not a field value, Measure, or Column).

DateAverage %
4/1/202075.4%
4/10/202083.4%

 

7 REPLIES 7
Anonymous
Not applicable

Hi @ghutchins 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your problem or share me with your pbix file from your onedrive business.

 

Best Regards,

Rico Zhou

@Anonymousno it did not.  To new to Power BI to understand why it worked for the randomized data example but not in my actual data set. Maybe due to the % being a calculated column and not just a list of values.

Anonymous
Not applicable

Hi @ghutchins 

If you want to calculate the average by DAX Calculated % measure, you may try my way.

I use measure to achieve your goal.

Avg =

var _a = SUMX(ALLEXCEPT('Table','Table'[Date]),[DAX Calculated %])

var _b = CALCULATE(COUNT('Table'[Location]),FILTER(ALL('Table'),'Table'[Date]=MAX('Table'[Date])))

return

DIVIDE(_a,_b)

Result:

6.png

You can download the pbix file from this link: Aggregation Problem in a Line Graph

 

Best Regards,

Rico Zhou

 

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

andre
Memorable Member
Memorable Member

basically, you gotta average it twice, first time by site and then by day... 

 

you need to do a variation of this calc but in your case you need to do values(site[siteid]) instead of values(customer[customerid])

 

Average Days Between Orders = 
AVERAGEX(
    ADDCOLUMNS(
        VALUES(Customer[CustomerID]),
        "Average Days Between Orders by Customer", 
        AVERAGE(Sales[Days Since Last Order])
    ),
    [Average Days Between Orders by Customer]
)

i explain how this calc works at 4:15 of this video

 

if you want to practice, you can find the model here: https://businessintelligist.com/2020/07/26/dax-tutorial-average-days-between-orders/

@andre

 

after listening to your video and applying it to my data I find that I have a flat 95% across the date range and still aggregated by Location.  Had to duplicate DAX Calculated % Measure as a Column to get your calculation accept it.   No joy.

 
Average All Locations by Date=
AVERAGEX(
    ADDCOLUMNS(
        VALUES(Location),
        "Average by Date",
        AVERAGE(DAX Calculated %)
    ),
    [Average by Date]
)
parry2k
Super User
Super User

@ghutchins create another measure for average

 

Avg % = 
AVERAGEX ( VALUES ( Table[Date] ), [Your % Measure] )

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2kYour AVERAGEX calculation did not work...  I still have multiple Locations for a single Date

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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