problem with calculating the average using variables defining a range of values
Hello
I am a beginner DAX user and I have a serious problem with calculating the average using variables defining a range of values.
The problem is as follows:
Table: 'public Measurement'
1. average value for the entire range (10 results) as a separate column - works well
AV_N =
CALCULATE (
AVERAGE ( 'public Measurement'[result]);
FILTER (
ALLSELECTED ('public Measurement');
'public Measurement'[characteristicId] = MAX ( 'public Measurement'[characteristicId])
)
)
The result of the measure is as follows
2. average value for 5 results as a separate column - it seems to work well but the value range is entered "manually"
average value from a range using variables (the measure doesn't work, why?)
Instead of constant values defining the average calculation range (1 and 5 ), I need to use variables.
the variable defining the final range of the value must be calculated, for example:
var stop = count('public measurement'[number]) (instead of the value 5)
How to use variables in such a measure?
Please help
welcome back
Thank you for your suggestions, it allowed me to locate the problem.
Instead of count() I used the countx() function and it works very well
thank you againvar stop_av = CALCULATE(COUNTX('public Measurement';'public Measurement'[number]);FILTER(ALLSELECTED('public Measurement');'public Measurement'[characteristicId] = MAX('public Measurement'[characteristicId])))