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
mvananaken
Helper II
Helper II

Lastdate in directquery mode for more then 1 same dates (same date, different time)

Hello Folks,

 

I would like to create a measure to show te latest temp value based on the last date in Direct Query Mode. I turn on "allow unrestricted measures in Direct Query mode, and now the LASTDATE function is possible to use (?). But now the following problem occurs:

 

 

I tried it with: Last Datavalue = SUMMARIZECOLUMNS('GenSens'[Temp],LASTDATE('GenSens'[Time]))  

Error: " date column containing duplicates dates was specified in the call to function LASTDATE.  Ok, I've got values like (same date, different time). 

 

Date                                      Temp

11/16/2016 2:30:20PM        21.50

11/16/2016 2:28:20PM           20.32

 

 

How to realize this with a measure, cause a calculated column / calculated table or create a date dimension in Direct Query is not possible. 

 

 

Any ideas? Ty!

 

 

2 ACCEPTED SOLUTIONS
v-huizhn-msft
Employee
Employee

Hi @mvananaken


As I tested, the LASTDATE function is not supported in DirectQuery even through I turn on "allow unrestricted measures in Direct Query mode”. My Power BI desktop version is 2.40.4554.463 64-bit (October 2016).

 
1.png

SUMMARIZECOLUMNSFunction returns a summary table over a set of groups. You need create a new table when you use SUMMARIZECOLUMNS() function. But the New Table is unable when you connect database using Direct Query. So the function is also not supported.

 
2.png


You can try to solve the issue by creating a measure like Last Datavalue = CALCULATE(MAX('GenSens'[Time]), ALLEXCEPT ('GenSens','GenSens'[Temp])), then create a table shown what you want.

For example, I create the following measure and table. Select the LoginID and Measure2 as Values level, which displays LoginID based in the lasted HireDate.

Measure 2 = CALCULATE(MAX('HumanResources Employee'[HireDate]),ALLEXCEPT('HumanResources Employee','HumanResources Employee'[LoginID]))

3.png 

Best Regards,
Angelia

 

View solution in original post

Hi @mvananaken,

 As descripbed in above solution, I calculate the max date for each LoginID. If you just want to display one column, you can use MAX(Table[datetime]) without filter. It will return the max date of the datetime column rather than LoginID.

If this is not what you want, please  share a snapshot for your single "Card" visual or sample date for futher analysis.

Best Regards,
Angelia

View solution in original post

3 REPLIES 3
v-huizhn-msft
Employee
Employee

Hi @mvananaken


As I tested, the LASTDATE function is not supported in DirectQuery even through I turn on "allow unrestricted measures in Direct Query mode”. My Power BI desktop version is 2.40.4554.463 64-bit (October 2016).

 
1.png

SUMMARIZECOLUMNSFunction returns a summary table over a set of groups. You need create a new table when you use SUMMARIZECOLUMNS() function. But the New Table is unable when you connect database using Direct Query. So the function is also not supported.

 
2.png


You can try to solve the issue by creating a measure like Last Datavalue = CALCULATE(MAX('GenSens'[Time]), ALLEXCEPT ('GenSens','GenSens'[Temp])), then create a table shown what you want.

For example, I create the following measure and table. Select the LoginID and Measure2 as Values level, which displays LoginID based in the lasted HireDate.

Measure 2 = CALCULATE(MAX('HumanResources Employee'[HireDate]),ALLEXCEPT('HumanResources Employee','HumanResources Employee'[LoginID]))

3.png 

Best Regards,
Angelia

 

Hello @v-huizhn-msft,

 

Thanks  for reply! This still works in a table with 2 columns, but I tried to show the max value in a single " card"  visual. (and then it shows the date only, not the max value).

 

Kind regards,

 

Marco

Hi @mvananaken,

 As descripbed in above solution, I calculate the max date for each LoginID. If you just want to display one column, you can use MAX(Table[datetime]) without filter. It will return the max date of the datetime column rather than LoginID.

If this is not what you want, please  share a snapshot for your single "Card" visual or sample date for futher analysis.

Best Regards,
Angelia

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.