Forum Discussion

JustinDoh1's avatar
JustinDoh1
Post Prodigy
11 months ago
Solved

Question on AVERAGEX

I have been using this DAX for long time, and now I would like to analyze it. I have uploaded my PBIX file here.   Here is my DAX:   Averagex = AVERAGEX(         FILTER             (       ...
  • v-dineshya's avatar
    11 months ago

    Hi JustinDoh1 ,

    Thank you for reaching out to the Microsoft Community Forum.

     

    Please check below steps for detail explaination of your DAX code with sample example.

     

    1. SUMMARIZE ( 'Table', 'Date'[DateFormat], "ClientID_M", [ClientID_M] )

    The above syntax produces a virtual table with One row per 'Date'[DateFormat]. A calculated column "ClientID_M" holding the value of your [ClientID_M] measure for that date. You are trying to generate like below sample data.

     

    DateFormat    ClientID_M

    01-01-2025     12
    02-01-2025     15
    03-01-2025      0


    2. FILTER ( … , [ClientID_M] > 0 ), It removes rows where [ClientID_M] <= 0, so you are trying to ignore zeros/negatives. Now your virtual table looks like below sample data.

     

    DateFormat    ClientID_M


    01-01-2025    12
    02-01-2025    15

     

    3. AVERAGEX ( table, [ClientID_M] ), It iterates over each row in that filtered summarized table, and evaluates [ClientID_M] for that row. It is the average of [ClientID_M] across all dates where it’s > 0.

     

    Note: Your measure calculates the average of [ClientID_M] at the date level (one row per DateFormat), ignoring the dates where the measure is 0 or negative.

     

    I hope this information helps. Please do let us know if you have any further queries.

     

    Regards,

    Dinesh