Forum Discussion

MillarJayakumar's avatar
MillarJayakumar
Frequent Visitor
2 years ago

power dax

Not getting desire output for 12 month rolling average calcuation. any one assist me why i am not getting expected 12 MRA out put

 

Dax code :

 

12mra final =
 var nmonth =12
 var LCDate =max('DMADP OPEM_ADP_DATE_D'[Date])
 var Period =DATESINPERIOD('DMADP OPEM_ADP_DATE_D'[Date],LCDate,-nmonth,MONTH)
 Var result =
 CALCULATE(
 AVERAGEX(VALUES('DMADP OPEM_ADP_DATE_D'[Year Month]),[TRs Count]),Period)
 return
 if([TRs Count]>0,result)
 

 

3 Replies

  • aj1973's avatar
    aj1973
    Community Champion

    Hi MillarJayakumar 

    Did you add a Date Table to your Model? DATESINPERIOD() is a Time Intelligence function that needs a Date Table without gaps.

    Besides in your graph seems like you are using Year-Month in the X Axis while in your measure you are using 

    [Year Month] with no dash!

     

    • MillarJayakumar's avatar
      MillarJayakumar
      Frequent Visitor

      1)it has a relationship 

      2)DATESINPERIOD() is a Time Intelligence function that needs a Date Table without gaps-then its show error right while creating. but its not showing any error

      3)Year-Month in the X Axis while in your measure you are using 

      [Year Month] with no dash!- corrected everthough it not working 

      • aj1973's avatar
        aj1973
        Community Champion

        Can you share a Sample please?