Forum Discussion
Graph doesn't place average per year correctly
- 3 years ago
Hi!
Based on your description and the DAX formula provided, I see a couple of potential issues:
-
Naming Convention: The way you've named your tables and columns is a bit confusing. For instance, having a table named
'amount of unique visitors'and then a column within that table named'[amount of unique visitors]'can be misleading and cause potential mistakes. -
AVERAGEX: This function averages the results of an expression calculated for each row in a table. It's important to ensure that the expression used inside
AVERAGEXis accurately capturing what you want to average. In your case, you're just referencing the column, which might not be yielding what you intend. -
ALL function: When using the
ALLfunction in conjunction withFILTER, you're effectively removing any filters on theDatedimension[Datekey]and then reapplying them based on the conditions you specified in theFILTERfunction. It's not inherently wrong, but it's worth noting in case there are any other filters being applied elsewhere in your model that you would want to consider.
Let's try to address the problems and refine the formula:
AverageUniqueVisitors2016 = CALCULATE( AVERAGE('amount of unique visitors'[amount of unique visitors]), FILTER( ALL(Datedimension[Datekey]), Datedimension[Datekey] >= DATE(2016, 1 , 1) && Datedimension[Datekey] <= DATE(2016,12,31) ) ) -
Hi!
Based on your description and the DAX formula provided, I see a couple of potential issues:
-
Naming Convention: The way you've named your tables and columns is a bit confusing. For instance, having a table named
'amount of unique visitors'and then a column within that table named'[amount of unique visitors]'can be misleading and cause potential mistakes. -
AVERAGEX: This function averages the results of an expression calculated for each row in a table. It's important to ensure that the expression used inside
AVERAGEXis accurately capturing what you want to average. In your case, you're just referencing the column, which might not be yielding what you intend. -
ALL function: When using the
ALLfunction in conjunction withFILTER, you're effectively removing any filters on theDatedimension[Datekey]and then reapplying them based on the conditions you specified in theFILTERfunction. It's not inherently wrong, but it's worth noting in case there are any other filters being applied elsewhere in your model that you would want to consider.
Let's try to address the problems and refine the formula:
AverageUniqueVisitors2016 =
CALCULATE(
AVERAGE('amount of unique visitors'[amount of unique visitors]),
FILTER(
ALL(Datedimension[Datekey]),
Datedimension[Datekey] >= DATE(2016, 1 , 1) &&
Datedimension[Datekey] <= DATE(2016,12,31)
)
)