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
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
Employee
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
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.