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
Mous007
Helper IV
Helper IV

calculated average not matching with Average line on visual

Hi all,

 

So i have a small issue with averages and i can't figure the reason why as I want to report the same value on both visuals.

 

So in the following screen shot when i select a specific period the averages are matching on the card and graph.

ss1.JPG

 

 

The issue is when i have no specific period selected. i was expecting the same average result on the chart average line to be on the card if no period is selected  as i believe is the correct one after a quick check on excel. Please refer to the screenshot below to see the difference in results.

 

ss2.JPG

 

so my question is how can i alter my calculation to show the exact average as on the average line on the graph when no specific date is selected ?

 

Any help or hints would be really appreciated and if you need any extra information i would be happy to privde it .

 

Thanks in advance.

Mous

 

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

Hi @Mous007 ,

 

The following is my simple sample. You could reference it to modify yours.

 

Firstly, you need to create a new table and use date its column as the period slicer. 

Note: There is no relationship between the tables.

 

Example:

 

New date table = DISTINCT('Table'[Date])

 

 

Then create a measure like below:

(Please change the variable of avg_filtered  to your expression : % of requests without failures. )

 

Total_sales = SUM('Table'[Sales])


avg_date =
VAR avg_filtered =
    AVERAGE ( 'Table'[Sales] )
RETURN
    IF (
        ISFILTERED ( 'New date table'[Date] ),
        avg_filtered,
        AVERAGEX ( ALLSELECTED ( 'Table'[Date] ), [Total_sales] )
    )

 

3.PNG

 

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

View solution in original post

3 REPLIES 3
Smauro
Solution Sage
Solution Sage

Hi @Mous007 

You don't have a calculation issue, rather a "Power BI is kinda stupid" issue.

You see, the automatic average line is not a weighted average:

<u+202d>79.2   +   77.91   +   73   +   86.6   +   78.17   +   88.89 =<u+202c> 483.77
483.77   ÷   6 ~= 80.63

Whereas the total's calculation is..6 +

Cheerss the t





Feel free to connect with me:
LinkedIn

v-xuding-msft
Community Support
Community Support

Hi @Mous007 ,

 

The following is my simple sample. You could reference it to modify yours.

 

Firstly, you need to create a new table and use date its column as the period slicer. 

Note: There is no relationship between the tables.

 

Example:

 

New date table = DISTINCT('Table'[Date])

 

 

Then create a measure like below:

(Please change the variable of avg_filtered  to your expression : % of requests without failures. )

 

Total_sales = SUM('Table'[Sales])


avg_date =
VAR avg_filtered =
    AVERAGE ( 'Table'[Sales] )
RETURN
    IF (
        ISFILTERED ( 'New date table'[Date] ),
        avg_filtered,
        AVERAGEX ( ALLSELECTED ( 'Table'[Date] ), [Total_sales] )
    )

 

3.PNG

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
parry2k
Super User
Super User

@Mous007 without knowing how your tables are related and what is your measure, it is not easy to answer the question. Read this post to get your answer quickly.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



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.

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.