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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
aamirkhan_WT
Helper II
Helper II

How to take To Date from Date range using Dax

Hi All,

 

I want to Pick To Date only  which I have highlight below using dax and As I am using Date ranges as well

Capture.PNG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,
Try the following dax formula.

 

Previous year = CALCULATE(SUM('Table'[Sales]), FILTER(ALL('Table'), 'Table'[Date] <= MAX('Table'[Date]) && 'Table'[Year] = YEAR(TODAY())))

 

vjiewumsft_0-1724746567476.png

Best Regards,

Wisdom Wu

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

8 REPLIES 8
Anonymous
Not applicable

Hi @aamirkhan_WT ,

Based on my testing, please try the following methods:

1.Create the sample table.

vjiewumsft_0-1724143474559.png

2.Create the measure to get the To date and from date.

To Date = MAX('Table'[Date])
From Date = MIN('Table'[Date])

3.Drag the measure into the card visual.

vjiewumsft_2-1724143489755.png

Best Regards,

Wisdom Wu

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

Yes but how to calculate  Previous period and Previous Year sales from To Date selection. if you show me in the same pbi file 

Anonymous
Not applicable

Hi @aamirkhan_WT ,

Please try the following methods:

1.Create the sample table.

vjiewumsft_0-1724218108089.png

2.Create the new measure to calculate previous period and previous year.

Previous year = CALCULATE(SUM('Table'[Sales]), FILTER(ALL('Table'), 'Table'[Year] = YEAR(MAX('Table'[Date])) - 1))
Previous preiod = CALCULATE(SUM('Table'[Sales]), DATESBETWEEN('Table'[Date], MIN('Table'[Date]), MAX('Table'[Date])))

3.Drag the measures into the card visual. Select the to date.

vjiewumsft_1-1724218119474.png

Best Regards,

Wisdom Wu

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

this Dax is considering From date or base on To Date as I need to work from To Data only 

Previous preiod = CALCULATE(SUM('Table'[Sales]), DATESBETWEEN('Table'[Date], MIN('Table'[Date]), MAX('Table'[Date])))
Anonymous
Not applicable

Hi,
Try the following dax formula.

 

Previous year = CALCULATE(SUM('Table'[Sales]), FILTER(ALL('Table'), 'Table'[Date] <= MAX('Table'[Date]) && 'Table'[Year] = YEAR(TODAY())))

 

vjiewumsft_0-1724746567476.png

Best Regards,

Wisdom Wu

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

rubayatyasmin
Super User
Super User

Hi, @aamirkhan_WT 

 

You mean, you want to get the max date? 

 

MAX(YourDateTable[Date]) - Should do the work


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


If I select date  from date range which I have highlight (To Date) for example 3/31/2024 or 3/21/2024 and from Date if it select 1/31/2024 which is fixed will it show 3 months using Dax 

Hi,

 

It would be really helpful if you write your query property. it is not clear what you exactly want to achieve.

 

Thanks,

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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