Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi,
Im calculating number of months in two different years.That means if i select date filter from 2020 jan 1st to todate i need to show 2020 has 12 months and 2021 has 02 months todate from january.i want to show 02 cards seperately to show months.is there a way to do this? I tries Datediff. But it shows months count form 2020 to todate. Can someone help me to get this?
Thanks
Solved! Go to Solution.
Hi @Anonymous
Will you only select dates in two adjacent years? Will you always filter a data range until today?
If you only filter dates in last year and this year, you can create below measures:
If the last year will not always be 2020, you can modify Measure A like below:
If you will not always use today as the last date of your date selection, you can use below measures:
All of above measures don't deal with the conditions if you select dates period in more than 2 years or in only a single year. Let me know if you have more conditions and I can modify the measures accordingly.
Additionally, I believe we can use simpler measures like below.
Regards,
Community Support Team _ Jing Zhang
If this post helps, please consider Accept it as the solution to help other members find it.
@AnonymousDoes my reply solve your problem? If yes, kindly accept it as the solution. Otherwise, please provide more details about your problem so that we can work on it further. Thanks.
Hi @Anonymous
Will you only select dates in two adjacent years? Will you always filter a data range until today?
If you only filter dates in last year and this year, you can create below measures:
If the last year will not always be 2020, you can modify Measure A like below:
If you will not always use today as the last date of your date selection, you can use below measures:
All of above measures don't deal with the conditions if you select dates period in more than 2 years or in only a single year. Let me know if you have more conditions and I can modify the measures accordingly.
Additionally, I believe we can use simpler measures like below.
Regards,
Community Support Team _ Jing Zhang
If this post helps, please consider Accept it as the solution to help other members find it.
@Anonymous , Measures like these
new measure =
if(year(Selectvalue(Date[Date])) < year(Today), datediff(Selectvalue(Date[Date]),date(year(Selectvalue(Date[Date]),12,31)), month),0)
new measure 2
datediff(today(), date(year(today()),1,1),month)
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!