Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello,
I am trying to create a measure to show a count of the average case created count per day over the last 21 days. I had Copilot help with a calulation but it is not returning any data. Any help appreciated
Solved! Go to Solution.
Hi @jdubs ,
Try to modify your formula like below:
Created_21avg =
VAR __LAST_DATE =
TODAY () - 1 -- Yesterday's date
RETURN
AVERAGEX (
DATESBETWEEN ( 'Cases'[createdon].[Date], __LAST_DATE - 21, __LAST_DATE ),
CALCULATE ( COUNTROWS ( 'Cases' ) )
)
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @jdubs ,
Try to modify your formula like below:
Created_21avg =
VAR __LAST_DATE =
TODAY () - 1 -- Yesterday's date
RETURN
AVERAGEX (
DATESBETWEEN ( 'Cases'[createdon].[Date], __LAST_DATE - 21, __LAST_DATE ),
CALCULATE ( COUNTROWS ( 'Cases' ) )
)
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hey Adamk,
Thank you. I think this is working! Just need to spot-check some data and will mark as solved!
Hi Greg,
I'm getting a syntax error which I thought was due to the double quotes, which I changed to single quotes, but it still doesn't seem to like [_Count] in the formula.
Alternatively, I tried this formula which actually does return data however it only ever returns "1" no matter what i change the day range to e.g. 21 vs. 5
21Day_avg = AVERAGEX(KEEPFILTERS(VALUES('Cases'[createdon])), CALCULATE(COUNTROWS('Cases'), KEEPFILTERS('Cases'[createdon] > NOW() - 21)))
@jdubs Try:
Created_21avg =
VAR __LastDate = MAX( 'Cases'[createdon] )
VAR __MinDate = __LastDate - 21
VAR __Table =
SUMMARIZE(
FILTER( 'Cases', 'Cases'[createdon] >= __MinDate && 'Cases'[createdon] <= __LastDate )
[createdon],
"__Count", COUNTROWS( 'Cases' )
)
VAR __Result = AVERAGEX( __Table, [__Count] )
RETURN
__Result
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
76 | |
75 | |
54 | |
38 | |
31 |
User | Count |
---|---|
99 | |
56 | |
50 | |
42 | |
40 |