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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

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!
 
babyjb123_0-1671834274594.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Please review your model relationships and create a measure.

vtangjiemsft_0-1672036453521.png

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.

vtangjiemsft_1-1672036520470.png

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. 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

 

Please review your model relationships and create a measure.

vtangjiemsft_0-1672036453521.png

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.

vtangjiemsft_1-1672036520470.png

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. 

FreemanZ
Super User
Super User

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
Not applicable

It doesn't work.

hi @Anonymous 

a bit strange, this was a verified proposal:

FreemanZ_0-1671950736615.png

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.