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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
andriikubrak
Frequent Visitor

Get latest values for N last days using DirectQuery

I have a table that has Date column and Value column. I am using SQL Server with DirectQuery mode. I need to build a chart that has latest values for each of 2 last days. Should look like here:

chart.png

 

Here is a table:

ANDRII-PC_SQLEXPRESS.MyDatabase - dbo.MyTable - Microsoft SQL Server Management Studio 2017-10-30 12.19.12.png

To achieve this I decided to create two calculated columns for X (days) and Y (values) axes. But I encountered issues when functions like MAX (to get most recent date) or FORMAT (to format date to "Fri" or "Sat") are not supported using DirectQuery in calculated columns. Does somebody have an idea how can I solve it?

 

1 REPLY 1
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @andriikubrak,

 

1. How to add dates like "Fri"?

1) If you can add a week column in the database, you can try to add a new column in the PBI.

Week =
LEFT ( [Day of Week], 3 )

2) If you can't, I wound if you can accept the format like this: "Sunday 1 January 2017".

 

2. About Max. Does the second max date have some features? For example, it's the max date minus 1. 

Because "Function 'FILTER' is not supported in this context in DirectQuery mode". We can't use filter to get the second max date. Or you have to do it in the database.

 

Best Regards!

Dale

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

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.

Top Solution Authors
Top Kudoed Authors