Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Use parameter in DAX

Hi all,

 

I created 2 parameters, one for year(2019-2023) , one for month(1-12). And created a new measure :

 

Selected last date = EOMONTH(DATE('Year Parameter'[Year Parameter Value],'Month Parameter'[Month Parameter Value],1),0)

 

Filter to Selected Date = DATEDIFF('Shop Account Ledger'[G/L Date],EOMONTH(DATE('Year Parameter'[Year Parameter Value],'Month Parameter'[Month Parameter Value],1),0),day)
 
My goal is to decide if the date is before or after the G/L date.  You can see the datediff is absolutly wrong, I don't know why. 
 
I really need help.
 
Thank you in advance!
Merry Christmas!
 

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    Please review your model relationships and create a measure.

    Filter to Selected Date = 
     var _lastdate=EOMONTH(DATE('Year Parameter'[Year Parameter Value],'Month Parameter'[Month Parameter Value],1),0)
     return DATEDIFF(SELECTEDVALUE('Shop Account Ledger'[G/L Date]),_lastdate,DAY)

    Then the result is as follows.

    Best Regards,

    Neeko Tang

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

4 Replies

  • hi Anonymous 

     

    try like:

    Filter to Selected Date = DATEDIFF( MAX( 'Shop Account Ledger'[G/L Date]),  EOMONTH(DATE('Year Parameter'[Year Parameter Value],'Month Parameter'[Month Parameter Value],1),0),day)

    • Anonymous's avatar
      Anonymous
      Not applicable

      It doesn't work.

      • FreemanZ's avatar
        FreemanZ
        Super User

        hi Anonymous 

        a bit strange, this was a verified proposal:

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Please review your model relationships and create a measure.

    Filter to Selected Date = 
     var _lastdate=EOMONTH(DATE('Year Parameter'[Year Parameter Value],'Month Parameter'[Month Parameter Value],1),0)
     return DATEDIFF(SELECTEDVALUE('Shop Account Ledger'[G/L Date]),_lastdate,DAY)

    Then the result is as follows.

    Best Regards,

    Neeko Tang

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