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
AaaaD1
Frequent Visitor

Average of GroupBy and sum

i have a table with date, status and values(with other column but these are the main ones), its daily data and i would like to have a chart that shows weekly average.
How can i summarize teh data on weekly level. i wnat to group the data based on dates and status and then show the weekly average.
can someone please help me with it.

 

thanks

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

Hi @AaaaD1 ,

If I understand correctly, the issue is that you want to group the data based on dates. Please try the following methods and check if they can solve your problem:

1.Create the simple table.

vjiewumsft_3-1707206382578.png

 

2.Create the new column.

 

weeknum = WEEKNUM('Table 2'[Date], 2)

 

 

3.Create the new measure to calculate.

 

Measure = CALCULATE(AVERAGE('Table 2'[values]), ALLEXCEPT('Table 2', 'Table 2'[status]), 'Table 2'[weeknum] = MAX('Table 2'[weeknum]))

 

 

4.Select the column chart visual and drag the field to the columns.

vjiewumsft_4-1707206450334.png

 

5.The result is shown below.

vjiewumsft_5-1707206477680.png

 

 

 

Best Regards,

Wisdom Wu

View solution in original post

3 REPLIES 3
v-jiewu-msft
Community Support
Community Support

Hi @AaaaD1 ,

If I understand correctly, the issue is that you want to group the data based on dates. Please try the following methods and check if they can solve your problem:

1.Create the simple table.

vjiewumsft_3-1707206382578.png

 

2.Create the new column.

 

weeknum = WEEKNUM('Table 2'[Date], 2)

 

 

3.Create the new measure to calculate.

 

Measure = CALCULATE(AVERAGE('Table 2'[values]), ALLEXCEPT('Table 2', 'Table 2'[status]), 'Table 2'[weeknum] = MAX('Table 2'[weeknum]))

 

 

4.Select the column chart visual and drag the field to the columns.

vjiewumsft_4-1707206450334.png

 

5.The result is shown below.

vjiewumsft_5-1707206477680.png

 

 

 

Best Regards,

Wisdom Wu

AaaaD1
Frequent Visitor

@saurabhtd  thanks for reaponding

actually i need it in a stack bar chart where weeks are on x-axis and status is legend 
i created a endofWeek column and using it in x-axis then 
var _sum=sum(values)
return
averagex(selectcolumn(table,"date",table[Date],"status",table[status]),_sum)

this still doesn't give correct result, where am i going wrong

saurabhtd
Resolver II
Resolver II

@AaaaD1 You need to create a calculated column to extract the week of the year from date column present in the table. You can use the following formula:

Week = WEEKNUM(Date, 1)

here I have taken "1" since I am assuming Sunday as the first day of the week. Visit this link for more info on WEEKNUM WEEKNUM – DAX Guide 

DAX formula to calculate weekly average of values column group by week and status

Weekly Average =
VAR _week = SELECTEDVALUE('Table'[Week])
VAR _status = SELECTEDVALUE('Table'[Status])
RETURN
AVERAGEX(
FILTER(
'Table',
'Table'[Week] = _week
&& 'Table'[Status] = _status
),
[Values]
)

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.