Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Rolling 5 Month AVG DAX Returns Monthly Total Instead - Why?

Hi everyone,

I am stumped! I can't figure out why the two formulas below return the same result. Am I missing somethng really obvious?

 

ExD Month = CALCULATE(TOTALMTD(SUM('Ex-Distributor'[ExDistributor Sales]),'DateDim'[Date]))

 

Ex-UD AVG (Month) = CALCULATE(SUM('Ex-Distributor'[ExDistributor Sales]),DATESINPERIOD('Ex-Distributor'[Month],LASTDATE('Ex-Distributor'[Month]),-5,MONTH))/CALCULATE(DISTINCTCOUNT('Ex-Distributor'[Month]),DATESINPERIOD('Ex-Distributor'[Month],LASTDATE('Ex-Distributor'[Month]),-5,MONTH))

 

Thanks a lot!

 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , try somthing like this with date table

 

Rolling 5 = divide( CALCULATE(sum(Sales[Sales]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date]),-5,MONTH)) ,
CALCULATE(distinctCOUNT('Date'[Month Year]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-5,MONTH), not(isblank((Sales[Sales])))))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

View solution in original post

v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

Did you have a date table , you should use date column instead of month column in formula:

Ex-UD AVG (Month) =
CALCULATE (
    SUM ( 'Ex-Distributor'[ExDistributor Sales] ),
    DATESINPERIOD (
        'DimDate'[Date],
        LASTDATE ( 'DimDate'[Date] ),
        -5,
        MONTH
    )
)
    / CALCULATE (
        DISTINCTCOUNT ( 'DimDate'[Date] ),
        DATESINPERIOD (
            'DimDate'[Date],
            LASTDATE ( 'DimDate'[Date] ),
            -5,
            MONTH
        )
    )

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

 

View solution in original post

2 REPLIES 2
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

Did you have a date table , you should use date column instead of month column in formula:

Ex-UD AVG (Month) =
CALCULATE (
    SUM ( 'Ex-Distributor'[ExDistributor Sales] ),
    DATESINPERIOD (
        'DimDate'[Date],
        LASTDATE ( 'DimDate'[Date] ),
        -5,
        MONTH
    )
)
    / CALCULATE (
        DISTINCTCOUNT ( 'DimDate'[Date] ),
        DATESINPERIOD (
            'DimDate'[Date],
            LASTDATE ( 'DimDate'[Date] ),
            -5,
            MONTH
        )
    )

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

 

amitchandak
Super User
Super User

@Anonymous , try somthing like this with date table

 

Rolling 5 = divide( CALCULATE(sum(Sales[Sales]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date]),-5,MONTH)) ,
CALCULATE(distinctCOUNT('Date'[Month Year]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-5,MONTH), not(isblank((Sales[Sales])))))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.