Forum Discussion
DAX Measure to Average Terminations by Month
Seems like this should be simple, but I'm having a heck of a time.
I have an Employee table (dimWorker) with a field [Term Date}. I have a Date table (dimDate) with the date and the [Month Name]. They are propertly joined from dimWorker[Term Date] to dimDate[Date].
The business purpose is to show on average how many leave/terminate by month using line/bar chart to assess against a retention goal. The line chart will show [Month Name] on the x-axis and average terminations in the y-axis.
When I drop my terminations measure (see below) on the line chart with my visual filter selecting 2021, 2022, and 2023 I get an extremely high number (633). The january total should be 68 (average of 22.67) - jan 21 = 18; jan 22 = 24; jan 23 = 26:
- Anonymous2 years ago
Hi, Decal
Thank you very much for your reply, as well as the sample data provided. Here's the sample data I used:
Here's your DAX expression:
Based on this, I built another DAX expression as shown in the following image:
Terminations = IF ( ISINSCOPE ( dimDate[Date].[Year] ), [Terminations (Dynamic)], SUMX ( ALLSELECTED ( 'dimDate'[Date].[Year] ), [Terminations (Dynamic)] ) )When I select the corresponding year in the slicer, total updates correctly:
I've provided the PBIX file used this time below.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- Decal
Helper I
This visual might help you assess what's going on. You can see the right assignment to the month name, but the total jumps way up at the bottom.
- AnonymousNot applicable
Hi, Decal
Based on the image you provided, it looks like total is not showing up correctly. I guess your DAX expression might not properly exclude blank lines from this visual. I'm not very clear of the data in your picture which 633 is filtered.
Fixing Incorrect Totals in DAX • My Online Training Hub
In this article, a workaround for measure to be incorrect in the total matrix is proposed: use the SUMX function. Similar to this are:
Solved: Getting incorrect totals on matrix table - Microsoft Fabric CommunityYou can also use the summarize,summarizecolumn functions to solve this problem of incorrect totals.
Power BI: Totals Incorrect and how to Fix it - Finance BI (finance-bi.com)
In addition, you can refer the following links to try to solve your problem...
Why Your Total Is Incorrect In Power BI - The Key DAX Concept To Understand
Dax for Power BI: Fixing Incorrect Measure Totals
If you can provide some sample data that does not contain privacy, it will help you solve the problem at hand.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Decal
Helper I
I tried the SUMX solution with the temporary table and it gave me the same result.
Here is sample data.
EEID Term Date 1 1/24/2023 2 1/31/2022 3 1/25/2021 4 1/5/2021 5 1/7/2022 6 1/6/2023 7 1/18/2023 8 1/18/2023 9 1/31/2023 10 1/1/2022 11 1/10/2022 12 1/31/2022 13 1/27/2023 14 1/26/2023 15 1/19/2022 16 1/5/2023 17 1/15/2021 18 1/10/2021 19 1/12/2021 20 1/1/2021 21 1/15/2021 22 1/15/2021 23 1/10/2021 24 1/5/2021 25 1/8/2021 26 1/10/2022 27 1/1/2022 28 1/12/2021 29 1/29/2022 30 1/30/2022 31 1/21/2022 32 1/26/2022 33 1/30/2021 34 1/30/2021 35 1/15/2021 36 1/6/2021 37 1/7/2022 38 1/14/2022 39 1/17/2022 40 1/29/2021 41 1/2/2023 42 1/13/2023 43 1/6/2023 44 1/7/2023 45 1/31/2023 46 1/29/2023 47 1/24/2023 48 1/1/2023 49 1/20/2023 50 1/25/2022 51 1/25/2022 52 1/11/2023 53 1/11/2022 54 1/7/2022 55 1/20/2023 56 1/6/2023 57 1/12/2023 58 1/10/2022 59 1/18/2023 60 1/24/2022 61 1/2/2023 62 1/7/2022 63 1/28/2022 64 1/27/2023 65 1/10/2023 66 1/18/2021 67 1/26/2022 68 1/20/2023 The date table is in a separate table with the date and the month names.
Greatly appreciate the help. Very confused by this.
- AnonymousNot applicable
Hi, Decal
Thank you very much for your reply, as well as the sample data provided. Here's the sample data I used:
Here's your DAX expression:
Based on this, I built another DAX expression as shown in the following image:
Terminations = IF ( ISINSCOPE ( dimDate[Date].[Year] ), [Terminations (Dynamic)], SUMX ( ALLSELECTED ( 'dimDate'[Date].[Year] ), [Terminations (Dynamic)] ) )When I select the corresponding year in the slicer, total updates correctly:
I've provided the PBIX file used this time below.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.