Forum Discussion

0xygen27's avatar
0xygen27
Icon for Advocate II rankAdvocate II
9 years ago
Solved

Graph doesn't place average per year correctly

Dear community,   I am wondering what is wrong with my DAX formula or with my graph.   I made a graph with on the axis, date and  on values I placed average per year. The formula I am using to d...
  • technolog's avatar
    3 years ago

    Hi!

     

    Based on your description and the DAX formula provided, I see a couple of potential issues:

    1. 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.

    2. 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 AVERAGEX is accurately capturing what you want to average. In your case, you're just referencing the column, which might not be yielding what you intend.

    3. ALL function: When using the ALL function in conjunction with FILTER, you're effectively removing any filters on the Datedimension[Datekey] and then reapplying them based on the conditions you specified in the FILTER function. 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)
        )
    )