Forum Discussion

SUMESHKUMAR22's avatar
SUMESHKUMAR22
Helper IV
1 year ago
Solved

Calculate reference average line using DAX

Hi Team,

Urgent help!

Problem: Want to calculate the average reference line using DAX instead of using the line chart option.
PBIX File 
This average reference line should be dynamic to whatever time slicer we select in the above range. E.g.: for last 7 days its coming as Avg- 3 but how to calcuate this using DAX??



Thanks in advance!

  • gmsamborn's avatar
    gmsamborn
    1 year ago

    Hi SUMESHKUMAR22 

     

    Would a measure like this help?

    _My Avg = 
    AVERAGEX(
        ADDCOLUMNS(
            SUMMARIZE(
                ALL( 'Sample' ),
                'DIM Date'[Date],
                'Dim_Channels'[Channel]
            ),
            "__Value", [current base sum cal]
        ),
        [__Value]
    )

     

    Let me know if you have any questions.

2 Replies

  • Hi Team,

    Replaced the new pbix file within the above link. Please refer the Dax average line & in built average line . Let me know which is calculating the correct average?

    Thanks!

    • gmsamborn's avatar
      gmsamborn
      Super User

      Hi SUMESHKUMAR22 

       

      Would a measure like this help?

      _My Avg = 
      AVERAGEX(
          ADDCOLUMNS(
              SUMMARIZE(
                  ALL( 'Sample' ),
                  'DIM Date'[Date],
                  'Dim_Channels'[Channel]
              ),
              "__Value", [current base sum cal]
          ),
          [__Value]
      )

       

      Let me know if you have any questions.