cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Noak Member
Member

Latest Value Direct Query

Hi guys I need your assistance/tips in orders to present (with direct query connection) latest battery value.

 

for eample here's my sample data:

 

CellDateTimeBattery
7/20/2018 3:5397
7/25/2018 13:32100
7/25/2018 13:33100

 

I would like to create a measure that calculates the latest battery state (7/25/2018 13:33) 100.

 

TNX !.

BR,
Noa.
7 REPLIES 7
v-danhe-msft Super Contributor
Super Contributor

Re: Latest Value Direct Query

Hi @Noak,

Based on my test, you can refer to below steps:

1.I have entered some sample data in SQL Serve like the picture below and use the Power BI to get the data in Direct Query mode.

L.PNG

2.Create a measure.

Measure 2 = IF(CALCULATE(SUM(Table_4[CellDateTime]))=MAXX(ALL('Table_4'),'Table_4'[CellDateTime]),CALCULATE(SUM(Table_4[Battery])),BLANK())

3.Create a Table visual and add the field. Now you can see the result.

LLLLL.PNG

Regards,

Daniel He

 

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

Re: Latest Value Direct Query

Hi thank you for you assitance @v-danhe-msft,

Unfurtunatly it doesnt work as card visual.

 

Capture.PNG

BR,
Noa.
v-danhe-msft Super Contributor
Super Contributor

Re: Latest Value Direct Query

Hi @Noak,

If you want to show in the card,  you could use this measure:

Measure = CALCULATE(SUM(Table_4[Battery]),FILTER('Table_4','Table_4'[CellDateTime]=MAX('Table_4'[CellDateTime])))

 

A.PNG

Regards,

Daniel He

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

Re: Latest Value Direct Query

Hi @v-danhe-msft

Filter isnt support in direct query mode =\.

 

Any ideas?

BR,
Noa.
Noak Member
Member

Re: Latest Value Direct Query

Any thoughts? @Gethelp 

BR,
Noa.
v-danhe-msft Super Contributor
Super Contributor

Re: Latest Value Direct Query

Hi @Noak,

It could work on my side:

1.PNG

From your description that you could not ues the filter function, could you please check the "Allow unrestricted measures in DirectQuery mode" has been checked? And you could test the measure again.

2.PNG  

 

Regards,

Daniel He

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

Re: Latest Value Direct Query

Thank you @v-danhe-msft

 

Its works now, but it gives me the wrong output . Any ideas why it might happen?.Capture.PNGMax(Nano[CellDateTime])  => 8/2/2018 10:58:44 AM

CALCULATE(sum(Nano[Module44Bat]),FILTER(nano,Nano[CellDateTime]=Max(Nano[CellDateTime])) => 0

 

 

 

 

BR,
Noa.

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

New Badges

Incoming: New and Improved Badges

Exciting news: We've given our badges an overhaul and added brand news ones.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 253 members 2,738 guests
Please welcome our newest community members: