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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
qwertzuiop
Advocate III
Advocate III

Check first and lasttime of ID-Occurence

Hello Dear PowerBI Community

 

I would be very grateful, if you could help me.

As can be seen in the table, there are different transports with IDs.

I would like to check chronologically which message per transport ID is sent first and which last.

The result should be in a calculated table as in the example.

 

transportIDcreatedCheckOccurence
12322.10.2019 01:45FirstTime
12323.10.2019 03:15x
12324.10.2019 21:45x
45624.10.2019 22:11FirstTime
45624.10.2019 23:32LastTime
78924.10.2019 23:50FirstTime
78925.10.2019 03:30x
78925.10.2019 05:20LastTime
12325.10.2019 16:30x
12325.10.2019 19:12LastTime

 

Cheers!

qwertzuiop

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

@qwertzuiop 

no problem, it should work as column. set as solution if it will help

Column = 
var _first = calculate(MIN(Table1[created]);ALLEXCEPT(Table1;Table1[transportID]))
var _last = calculate(MAX(Table1[created]);ALLEXCEPT(Table1;Table1[transportID]))
var _trID = [transportID]

RETURN
SWITCH(TRUE();
[created] = _first && [transportID] =_trID; "FirstTime";
[created] = _last && [transportID] =_trID; "LastTime";
"x"
)

 

do not hesitate to give a kudo to useful posts and mark solutions as solution

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

13 REPLIES 13
az38
Community Champion
Community Champion

Hi @qwertzuiop 

try a measure

CheckOccurence = 
var _first = calculate(MIN(Table1[created]);ALLEXCEPT(Table1;Table1[transportID]))
var _last = calculate(MAX(Table1[created]);ALLEXCEPT(Table1;Table1[transportID]))
var _trID = SELECTEDVALUE(Table1[transportID])

RETURN
SWITCH(TRUE();
SELECTEDVALUE(Table1[created]) = _first && SELECTEDVALUE(Table1[transportID]) =_trID; "FirstTime";
SELECTEDVALUE(Table1[created]) = _last && SELECTEDVALUE(Table1[transportID]) =_trID; "LastTime";
"x"
)

 

do not hesitate to give a kudo to useful posts and mark solutions as solution

LinkedIn


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

thanks a lot.

Unfortunatelly it doesn't work.

Could you please send your work in a powerBI-File so I can check and unterstand it?

az38
Community Champion
Community Champion

@qwertzuiop 

 

https://ufile.io/z0rsrmnw 

 

do not hesitate to give a kudo to useful posts and mark solutions as solution

 

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Thank you so much for your fast answers.

Couls you upload the file directly in here.

I'm in a secure network which not allows to visit your url.

az38
Community Champion
Community Champion

@qwertzuiop 

There is no such option in the Community

 

Безымянный.png

 

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

a.PNG

 

Very strange.

To help you visualize my problem: I only have an x everywhere.

az38
Community Champion
Community Champion

@qwertzuiop 

I got it. YOu create a column, but need a measure. try measure

 

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
az38
Community Champion
Community Champion

@qwertzuiop 

it could be problem with delimiter. try use "," instead of my ";"

 

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Does not work when changing ; to ,

 

https://community.powerbi.com/t5/Desktop/Find-first-occurence-of-value/m-p/850429#M408093

please check this post.

Are you sure you can't do this as well?

 
az38
Community Champion
Community Champion

@qwertzuiop 

try a New Measure, not column. it should work 🙂

 

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Thank you very much @az38 

Now i could solve the problem and it works.

 

But is there a way for a calculated column too?

Would be better for me 😕

az38
Community Champion
Community Champion

@qwertzuiop 

no problem, it should work as column. set as solution if it will help

Column = 
var _first = calculate(MIN(Table1[created]);ALLEXCEPT(Table1;Table1[transportID]))
var _last = calculate(MAX(Table1[created]);ALLEXCEPT(Table1;Table1[transportID]))
var _trID = [transportID]

RETURN
SWITCH(TRUE();
[created] = _first && [transportID] =_trID; "FirstTime";
[created] = _last && [transportID] =_trID; "LastTime";
"x"
)

 

do not hesitate to give a kudo to useful posts and mark solutions as solution

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Thank you so much - you did a great job 🙂

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.