Forum Discussion
Value from max date
- Anonymous6 years ago
share your pbix.
and where are you adding this query
select A.* from dbo.events a
left join (select MachineID,max(EventRaised) _EVENT from dbo.[events]
Group by MachineID) b ON A.MachineID=B.MachineID AND a.EventRaised=B._EVENT
WHERE b._EVENT IS NOT NULLGet Data->Select Sql server -> ENter server name & database name->DirectQuery Mode-> Click on advance -> paste this query there ->
And load your data.
this will give you direct result set
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar
If I resolve your problem Mark it as a solution and give kudos.
That solved it not giving an error, but still dosnt return anything =(
In one your screenshot you are getting output.
Thanks
Pravin
- lukasjar6 years agoResolver I
Yes that screenshot is from the code written by amitchandak pasted below.
Now this code returns on 6 of the 11 MachineId I have. I do not understand why it dosnt send anything on the other ones as it has a TagId. The measure you pasted does not work for me. Can it have something to do with my date having date + timestamp? I am looking for the last timestamp. In query editor I have filtered down the data to just include the last day.LNBV = calculate(max(Events[TagId]);filter(Events;Events[EventRaised] = lastnonblankvalue(Events[MachineId];Events[EventRaised]))) - Anonymous6 years agoNot applicable
- Anonymous6 years agoNot applicable
hi lukasjar
Please check belox dax.
All MAx Tagid measure =var MachineID=SELECTEDVALUE(Events[Machine ID])var max_date__=calculate(max('Events'[EventRaised]),FILTER(ALL('Events'),Events[Machine ID]=MachineID))returnCALCULATE(MAX(Events[TagID]),FILTER(ALL('Events'),MachineID=MachineID && Events[EventRaised]=max_date__))MAx Tagid measure =var MachineID=SELECTEDVALUE(Events[Machine ID])var max_date__=calculate(max('Events'[EventRaised]),FILTER(ALL('Events'),Events[Machine ID]=MachineID))returnCALCULATE(MAX(Events[TagID]),FILTER('Events',MachineID=MachineID && Events[EventRaised]=max_date__))TagIDColumn =var max_date__=calculate(max(Events[EventRaised]),ALLEXCEPT('Events',Events[Machine ID]))returnCALCULATE(MAX(Events[TagID]),FILTER(Events,Events[Machine ID]=EARLIER(Events[Machine ID]) && Events[EventRaised]=max_date__))Makesure your EventRaised column of type datetime.Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar
If I resolve your problem Mark it as a solution and give kudos. - lukasjar6 years agoResolver I
Unfortunatly still not working.
The first two are working on a imported query, not on direct query.
The third solution you suggested I get an error message, pic below.
- Anonymous6 years agoNot applicable
Hi lukasjar ,
Please try the below measure:
TagIdN = var a=max('Events'[MachineId]) var b=CALCULATE(max('Events'[EventRaised]),ALLEXCEPT('Events',Events[MachineId])) var c= CALCULATE(max('Events'[TagId]),FILTER('Events','Events'[MachineId]=a&&'Events'[EventRaised]=b)) return cBest Regards
Rena
- Anonymous6 years agoNot applicable
Hi lukasjar
I have created your datset on sql server and created directQUery.
The above two measure are showing same result which i was getting using import.
DO one thing create new pbix file and check.
Measures are working fine with directquery and yah i need to look onto column issue.
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar
If I resolve your problem Mark it as a solution and give kudos. - Anonymous6 years agoNot applicable
hI lukasjar
Use below query while connecting to your datasource using directquery.
select A.* from dbo.events a
left join (select MachineID,max(EventRaised) _EVENT from dbo.[events]
Group by MachineID) b ON A.MachineID=B.MachineID AND a.EventRaised=B._EVENT
WHERE b._EVENT IS NOT NULLI have given you some measures in last post if you want your output using measures.
There are some limitation while creating Calculated column when source is directquery.
Hence calculate,Allexcept,filter and earlier are not working in previous formula.
Check it out here
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar
If I resolve your problem Mark it as a solution and give kudos. - lukasjar6 years agoResolver I
I do not understand why it is not working on my end then, but must be something wrong in what I am doing i guess.
I have done a new pbix file with a new query as you wrote in the second message. Still have the same result. Will try sending you a movie of the pbix and measurments.
select A.* from dbo.events a
left join (select MachineID,max(EventRaised) _EVENT from dbo.[events]
Group by MachineID) b ON A.MachineID=B.MachineID AND a.EventRaised=B._EVENT
WHERE b._EVENT IS NOT NULL - Anonymous6 years agoNot applicable
share your pbix.
and where are you adding this query
select A.* from dbo.events a
left join (select MachineID,max(EventRaised) _EVENT from dbo.[events]
Group by MachineID) b ON A.MachineID=B.MachineID AND a.EventRaised=B._EVENT
WHERE b._EVENT IS NOT NULLGet Data->Select Sql server -> ENter server name & database name->DirectQuery Mode-> Click on advance -> paste this query there ->
And load your data.
this will give you direct result set
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar
If I resolve your problem Mark it as a solution and give kudos.