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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
rpinxt
Solution Sage
Solution Sage

Selectcolumns to make new table and how to sort it

So from an existing table I was able to extract this :

rpinxt_0-1708682672550.png

The goal is to see by day how many time a person (name) spend on a process.

So for that I want to make a calculated column but then first I need to sort these 4 columns so

that per day, per name and per time I can see which process was worked on.

 

Because as you now see it it is not correct.

This is what the first name did on Feb 1st:

rpinxt_1-1708682857008.png

And also as you see here the sorting is not correct as time is all over the place.

 

Is there a way I can sort this new table?

So by date, then by name and then by time.

1 ACCEPTED SOLUTION

@rpinxt

output 

 

Column = 

var currenttime =  'Table'[Time]
var prev_time = 
SELECTCOLUMNS(
OFFSET(
    -1,
    SUMMARIZE(
        'Table',
        'Table'[Date],
        'Table'[name],
        'Table'[Time]
    ),
    ORDERBY( 'Table'[Date] ,asc, 'Table'[Time] , asc),
    PARTITIONBY('Table'[Name],'Table'[Date])
),"time",'Table'[Time]
)

return  DATEDIFF(prev_time,currenttime,MINUTE)

 

Column 3 = 
 SELECTCOLUMNS(
OFFSET(
    1,
     SUMMARIZE(
        'Table', 
        'Table'[Name],
         'Table'[Date],
          'Table'[Time] 
          ,'Table'[Column]
        ),
        ORDERBY( 'Table'[Date] ,asc, 'Table'[Time] , asc),
    PARTITIONBY('Table'[Name],'Table'[Date])
    ),"time",'Table'[Column]
)

 

then use in the visual, column3 

 hope this helps .

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

View solution in original post

8 REPLIES 8
rpinxt
Solution Sage
Solution Sage

Thanks @Daniel29195 this looks very impressive.

Although the partitionby seems to have an error but there is still output.

rpinxt_0-1708686260599.png

Put it now on my main table as there was no use for a new table.

 

Still these values are not entirely correct I guess:

rpinxt_2-1708686994108.png

I think the process Apply should show 74 minutes and the Folding Delivery 12 minutes etc.

And also the change in the day causes some problems. 

Should 'reset' at a day level when calculating.

 

 

@rpinxt

output 

 

Column = 

var currenttime =  'Table'[Time]
var prev_time = 
SELECTCOLUMNS(
OFFSET(
    -1,
    SUMMARIZE(
        'Table',
        'Table'[Date],
        'Table'[name],
        'Table'[Time]
    ),
    ORDERBY( 'Table'[Date] ,asc, 'Table'[Time] , asc),
    PARTITIONBY('Table'[Name],'Table'[Date])
),"time",'Table'[Time]
)

return  DATEDIFF(prev_time,currenttime,MINUTE)

 

Column 3 = 
 SELECTCOLUMNS(
OFFSET(
    1,
     SUMMARIZE(
        'Table', 
        'Table'[Name],
         'Table'[Date],
          'Table'[Time] 
          ,'Table'[Column]
        ),
        ORDERBY( 'Table'[Date] ,asc, 'Table'[Time] , asc),
    PARTITIONBY('Table'[Name],'Table'[Date])
    ),"time",'Table'[Column]
)

 

then use in the visual, column3 

 hope this helps .

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

@Daniel29195 thanks!
Unfortunately I get this on the first column:

rpinxt_0-1708691667356.png

 

Is it an exact copy as you have made in the pbix I sent?

@rpinxt it seems from the image, you ddidnt put the name of the column you are creating ,

you are starting your code with var = 

 

@rpinxt is it possible to share the pbix file to take a look at what is happening from your side ? 

 

🤦‍

You are right...sorry about that!

Looks indeed to be working.

Thanks a lot!!

@Daniel29195 

Yes I uploaded the pbix file here:

https://drive.google.com/file/d/1nV-2HYrQPcUIDiaO8XbZbz--3zHY7qzE/view?usp=drivesdk

 

Let me know if you cannot access.

Daniel29195
Super User
Super User

@rpinxt 

 

output

Daniel29195_0-1708685687528.png

 

 

caclulated column added to the table : 

Column = 

var currenttime =  'Table'[Time]
var prev_time = 
SELECTCOLUMNS(
OFFSET(
    -1,
    SUMMARIZE(
        'Table',
        'Table'[DateName],
        'Table'[name],
        'Table'[Time]
    ),
    ORDERBY( 'Table'[DateName] ,asc, 'Table'[Time] , asc),
    PARTITIONBY('Table'[name])
),"time",'Table'[Time]
)

return  DATEDIFF(prev_time,currenttime,MINUTE)

 

 

let me know if this helps .

 

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.