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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply

How to write DAX query for getting last 30 days from a column not from Date table

Hi, I have a requirement, where I need the last 30 days data based on a date column that is not from Date table.

My DAX query is : 

 

Medium_Resolution_Timestamp =
Var ART=calculate(AVERAGE(Source[MinutesRoundTotal]),filter(source,Source[Priority]="Medium"),DATESINPERIOD(Source[Resolved At].[Date],TODAY(),-30,DAY),'Calendar'[WeekDay- Weekend]="Weekday")
Var Result=if(isblank(Res),"No Data Available" & UNICHAR ( 10 ) &"Data displayed is: last 30 days since" & " (" & (today()-30) &")"& ". Priority is: Medium ",FORMAT(Res,"HH:MM" )& UNICHAR ( 10 ) & UNICHAR ( 10 ) & "HH:MM")
Return UNICHAR(10)
& Result
 
My requirement is to find the last 30 days avg resolution time with reference to 'Resolved At ' column. (Consider Resolved At date and find last 30 days data. For example, I need to find the data from 4/20 to5/20 baed on Resolved At column)
 
Please let me know if I can use DatesinPeriod for this .
 
Thanks,
Radhika Lanka
1 ACCEPTED SOLUTION
jeroendekker
Frequent Visitor

Hi
Dates in Period should reference a full data column in your Calendar. 

I guess something like this.


DATESINPERIOD
 ( Calender[Date], LASTDATE(Source[Resolved At])-30DAY )

I hope this helps.

 

P.s It helps If you format your DAX. Try www.daxformatter.com for tips.

View solution in original post

2 REPLIES 2

Thank you for all the responses. I am able to resolve the issue.

jeroendekker
Frequent Visitor

Hi
Dates in Period should reference a full data column in your Calendar. 

I guess something like this.


DATESINPERIOD
 ( Calender[Date], LASTDATE(Source[Resolved At])-30DAY )

I hope this helps.

 

P.s It helps If you format your DAX. Try www.daxformatter.com for tips.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors