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

How do I make a measure or column to get such a table?

I have a database with a table (the approximate view of the table in the screenshot is the upper table)
All data is written row by row. eventid 10 is a user connection,
eventid 12-disable.
How can I make a correct mearute or column to get the disconnect time next to the connection time in a neighboring column? (as in the screenshot-the lower table)

 

5ebed8ce29890964985277

 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @aignn 

Create calculated columns

rank = RANKX(FILTER(Sheet3,Sheet3[username]=EARLIER(Sheet3[username])),[ID],,ASC,Dense)

rank2 = ROUNDDOWN(DIVIDE(IF( MOD([rank],2)=0,[rank]-1,[rank]),2),0)+1

Then create measures

minid = CALCULATE(MIN(Sheet3[ID]),ALLEXCEPT(Sheet3,Sheet3[rank2],Sheet3[username]))

maxid = CALCULATE(MAX(Sheet3[ID]),ALLEXCEPT(Sheet3,Sheet3[rank2],Sheet3[username]))

eventid.1 = CALCULATE(MIN([eventid]),FILTER(ALLEXCEPT(Sheet3,Sheet3[username],Sheet3[rank2]),[ID]=[minid]))

eventid.2 = CALCULATE(MIN([eventid]),FILTER(ALLEXCEPT(Sheet3,Sheet3[username],Sheet3[rank2]),[ID]=[maxid]))

time.1 = CALCULATE(MIN(Sheet3[time]),FILTER(ALLEXCEPT(Sheet3,Sheet3[username],Sheet3[rank2]),Sheet3[eventid.1]=[eventid.1]))

time.2 = CALCULATE(MIN(Sheet3[time]),FILTER(ALLEXCEPT(Sheet3,Sheet3[username],Sheet3[rank2]),Sheet3[eventid]=[eventid.2]))

Capture3.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-juanli-msft
Community Support
Community Support

Hi @aignn 

Create calculated columns

rank = RANKX(FILTER(Sheet3,Sheet3[username]=EARLIER(Sheet3[username])),[ID],,ASC,Dense)

rank2 = ROUNDDOWN(DIVIDE(IF( MOD([rank],2)=0,[rank]-1,[rank]),2),0)+1

Then create measures

minid = CALCULATE(MIN(Sheet3[ID]),ALLEXCEPT(Sheet3,Sheet3[rank2],Sheet3[username]))

maxid = CALCULATE(MAX(Sheet3[ID]),ALLEXCEPT(Sheet3,Sheet3[rank2],Sheet3[username]))

eventid.1 = CALCULATE(MIN([eventid]),FILTER(ALLEXCEPT(Sheet3,Sheet3[username],Sheet3[rank2]),[ID]=[minid]))

eventid.2 = CALCULATE(MIN([eventid]),FILTER(ALLEXCEPT(Sheet3,Sheet3[username],Sheet3[rank2]),[ID]=[maxid]))

time.1 = CALCULATE(MIN(Sheet3[time]),FILTER(ALLEXCEPT(Sheet3,Sheet3[username],Sheet3[rank2]),Sheet3[eventid.1]=[eventid.1]))

time.2 = CALCULATE(MIN(Sheet3[time]),FILTER(ALLEXCEPT(Sheet3,Sheet3[username],Sheet3[rank2]),Sheet3[eventid]=[eventid.2]))

Capture3.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-juanli-msft
Community Support
Community Support

Hi @aignn 

Create measures

Capture2.JPG

time.1 = CALCULATE(MIN(Sheet3[time]),ALLEXCEPT(Sheet3,Sheet3[username]))

time.2 = CALCULATE(MAX(Sheet3[time]),ALLEXCEPT(Sheet3,Sheet3[username]))

eventid.1 = CALCULATE(MIN([eventid]),FILTER(ALLEXCEPT(Sheet3,Sheet3[username]),Sheet3[time]=[time.1]))

eventid.2 = CALCULATE(MIN([eventid]),FILTER(ALLEXCEPT(Sheet3,Sheet3[username]),Sheet3[time]=[time.2]))

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-juanli-msft 

Thanks. I forgot that eventid2 can still be NULL(12 or null). Ie it is necessary to output also if eventid1=17, and eventid2=Null

How do I do it correctly in this case? Thanks in advance

amitchandak
Super User
Super User

@aignn , try measure like

 

time_1 = LASTNONBLANKVALUE(table[username], maxx(filter(table,table[eventid]=10),table[time]))
time_2= LASTNONBLANKVALUE(table[username], maxx(filter(table,table[eventid]=12),table[time]))

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.