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
a-taylor
Regular Visitor

Average by category with date slicer

Hi. So I am am pretty new to Power BI and I am trying to take these two columns (simplified fake versions of the real data) and get some specific visualizations but I am really stuck. I want the average number of tags per person per group, and I want it dividable by a time slicer. 

 

Basically, I want to be able to look at the whole thing and see what the average number of tags per person overall, and I want to be able to slice it by a time range. I want to then be able to select a group and see the average per that group. 

 

Table 1

persongroup
agroup_1
bgroup_1
cgroup_2
dgroup_2

 

Table 2

persondatetag
a9/6/2019foo
a9/6/2019foo
a9/6/2019foo
a9/4/2019bar
a9/2/2019bar
b9/6/2019foo
b9/6/2019bar
b9/5/2019bar
b9/6/2019bar
c9/4/2019foo
c9/2/2019foo
c9/1/2019foo
d9/4/2019foo
d9/5/2019foo
d9/3/2019foo
d9/5/2019bar
d9/2/2019bar
d9/3/2019bar

 

I tried to make a new table with SUMMARIZE that had the totals per person, with a relationship with the table 1 making it so I could look at it per group, but I couldn't figure out how to get the date slicer to affect it. I feel like I am missing something basic but I can't figure it out. Thank you so much for your help. 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Try this.

  1. Build a Calendar Table and create a relationship from the Date column of Table 2 to the Date column of the Calendar Table
  2. Build your Date slicer from the Calendar Table
  3. Create a relationship fro the Table 2 to Table 1 based on the Person column
  4. to your visual, drag Person from Table 1
  5. Write this measure = AVERAGEX(SUMMARIZE(VALUES('Table 1'[Person]),'Table 1'[Person],"ABCD",COUNTROWS('Table 2')),[ABCD])

Hope this helps.


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

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Try this.

  1. Build a Calendar Table and create a relationship from the Date column of Table 2 to the Date column of the Calendar Table
  2. Build your Date slicer from the Calendar Table
  3. Create a relationship fro the Table 2 to Table 1 based on the Person column
  4. to your visual, drag Person from Table 1
  5. Write this measure = AVERAGEX(SUMMARIZE(VALUES('Table 1'[Person]),'Table 1'[Person],"ABCD",COUNTROWS('Table 2')),[ABCD])

Hope this helps.


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

That worked! Thank you so much! 

Thank you.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

Based on the 2 Tables that you have shared, show the exact expected result.


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

Sorry. I can't get the expected result to happen but I can describe it, but it would be a visualization of a bar graph with the values field being the average of the total number of tags per person, the x axis would be the group and it would be dependant on a date range slicer. 

I can figure out a table like this, that shows the total number of tags per person by using SUMMARIZE(Table2, Table2[person], COUNTA(Table2[tags])):

persontotalTags
a5
b4
c3
d

6

And I can figure out how to make the graph based on that (Making a measure of AVERAGE(Table_3[totalTags]), and then having that be the value in the bar graph). But I can't figure out how to make that this depend on the date. I want to be able to look at the average per group on each day, or during a particular range. Ideally, I would be able to also have a separate visualization that has the day as the x-axis and the group as the slicer, but that is less important. 

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.