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.
Hello all,
I am pulling my hair out with an AVERAGEX formula
Solved! Go to Solution.
@Anonymous
Try this
Water TRIFR 12MMA =
VAR monthrange = 12
VAR result =
DIVIDE (
SUMX (
DATESINPERIOD (
'Calendar'[Date],
LASTDATE ( 'Calendar'[Date] ),
-1 * monthrange,
MONTH
),
[Water TRIFR]
),
monthrange,
BLANK ()
)
RETURN
result
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂
@Anonymous
Try this
Water TRIFR 12MMA =
AVERAGEX (
DATESINPERIOD (
'Calendar'[Date].[Date],
LASTDATE ( 'Calendar'[Date].[Date] ),
-12,
MONTH
),
[Water TRIFR]
)
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂
Here is my latest blog
https://community.powerbi.com/t5/Community-Blog/Dynamic-Page-Navigation-Based-on-User-Login/ba-p/1097786
I think I am going to throw my laptop into the air like a disc and shoot it!!
Here are the components. each in a table. A,B & C Individually are all correct but "D"
Table A is just the COUNT formula from my previous post looking for "injury". This is all correct
Table B is a fixed amount that never changes. So again correct
Table C is ... (Table A x 1,000,000) / Table B. So if I do a quick manual check for Jul 19... (3 x 1,000,000) / 96,000 = 31.25
So with rounding Table C July 19 = 31.25 which is correct
Now Table D is the AVERAGEX formula using TABLE C as the data.. What the points SHOULD be is.
Jul 19 - (0+0+0+0+0+0+0+0+0+0+0+31.25) / 12 = 2.6
Aug 19 - (Zero's + 31 + 10) / 12 = 3.4
Sept 19 - (Zero's + 31 + 10 + 42) / 12 = 6.92
Etc...
Apr 20 ( 0 + 0 + 31 + 10 + 42 + 10 + 10 + 31 + 10 + 21) / 12 = 13.75
So not only are the numbers incorrect but there is some odd behaviour that for 7 months its reading a constant figure??
@Anonymous
I think your slicer is making the problem. Because you are applying a slicer to filter the date. At the same time, you are looking for the last 12-month average. So you have to apply all() function to remove this filter. Then only you will get the previous 12 months in your context.
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂
@Anonymous
Try this measure.
Water TRIFR 12MMA =
AVERAGEX (
DATESINPERIOD (
ALL ( 'Calendar'[Date] ),
LASTDATE ( 'Calendar'[Date] ),
-12,
MONTH
),
[Water TRIFR]
)
If you can share the dataset, I can validate it.
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂
I would except the data is very sensitive and contains medical and personal contact information 😞
There was also an error with that DAX?
If I reduce the data and remove all of the non-essential stuff to this problem it would only be
Incident # | Date Reported | Report Type |
1 | 1/7/19 | Injury |
2 | 1/8/19 | Non-Injury |
3 | 20/8/19 | Injury |
4 | 14/9/19 | Injury |
5 | 4/1/20 | Non-Injury |
6 | 18/2/20 | Non-Injury |
7 | 24/3/20 | Non-Injury |
8 | 24/3/20 | Injury |
9 | 2/4/20 | Non-Injury |
This is example only. I didnt get exact dates from actual data
@Anonymous
Try this
Water TRIFR 12MMA =
VAR monthrange = 12
VAR result =
DIVIDE (
SUMX (
DATESINPERIOD (
'Calendar'[Date],
LASTDATE ( 'Calendar'[Date] ),
-1 * monthrange,
MONTH
),
[Water TRIFR]
),
monthrange,
BLANK ()
)
RETURN
result
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂
How do I attach an xls file? there is no options?
I created a table and pasted the data but it re-arranged all the cells?
I'm not 100% sure how the graph on the bottom right relates to the AVERAGEX measure in question?
What is the DAX formula for [Water TRIFR] and what does that Measure look like when plotted against the same time period in the same report and page as the graph on the bottom left?
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Hey,
So the graph on the bottom right is a DAX formula that looks through a data set and counts the number of entries that have the correct value. Here is the DAX for that
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |