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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
lost_flower
Helper III
Helper III

Average is not working

Hi,

 

I have the numbers of customers of two months and want to show the average.

lost_flower_0-1678045331963.png

 

This visual is the sum of customers with code: 

customer[count_no] = IF(ISBLANK(customer[name]),BLANK(),1)

 

For the average I tried a measure:

 

count_AVG =
VAR _AverageTable =
    ADDCOLUMNS (
        VALUES ( 'Date'[Date].[Month] ),
        "count"COUNT ( customer[count_no] )
    )
RETURN
    AVERAGEX( _AverageTable, [count] )
 
Average should be 177, but my code shows 354. Always the sum
lost_flower_0-1678046386977.png

 


 

 

Does anyone have an idea what is wrong with my measure?

 

Thank you

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @lost_flower 

try like:

count_AVG =
VAR _AverageTable =
    ADDCOLUMNS (
        VALUES ( 'Date'[Date].[Month] ),
        "count",

 CALCULATE(COUNT ( customer[count_no] ))

RETURN
    AVERAGEX( _AverageTable, [count] )

View solution in original post

7 REPLIES 7
FreemanZ
Super User
Super User

hi @lost_flower 

try like:

count_AVG =
VAR _AverageTable =
    ADDCOLUMNS (
        VALUES ( 'Date'[Date].[Month] ),
        "count",

 CALCULATE(COUNT ( customer[count_no] ))

RETURN
    AVERAGEX( _AverageTable, [count] )

Awesome! It works. Thank you so much 🙂

andhiii079845
Solution Sage
Solution Sage

Tell us more about how you use this measure. Do you use a slicer?VALUES ( 'Date'[Date].[Month] ) seems you want to calulcated the average within a monthy group. 
Can you show the underlaying data for a given example, please. It is very difficult to understand the probem. 
Do you check the interaction between slicer and bar chart? 

Did the measure change, if you change the slicer. Can you please check if 354 is the average for the complete year 2022. I think in your measure miss a ALLSELECT(). 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




yes, date (year and month) is used as a slicer, that also change the measure.

354 is always the sum of the selected months.

 

My data looks like:

lost_flower_0-1678050000972.png

 

Does that help?

yes, date (year and month) is used as a slicer, that also change the measure.

354 is always the sum of the selected months.

 

My data looks like:

NetamountMonthYearClientnoDatenamecustomer
10,0011993253401.01.1993customer 11
20,0011993347501.01.1993customer 21
20,0011993347501.08.1993  
30,0011993586601.06.1993customer 41
30,0011993273501.02.1993  

 

Does that help?

andhiii079845
Solution Sage
Solution Sage

Why you add VALUES ( 'Date'[Date].[Month] ) in your DAX? Date and customer table have a relationship?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi, 

 

yes, they have. table "date" is my calender table. 
I used VALUES, because it does work for another table. Happy to know how it could work with something else

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.