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
rpinxt
Impactful Individual
Impactful Individual

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
Impactful Individual
Impactful Individual

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! 🤠

rpinxt
Impactful Individual
Impactful Individual

@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 ? 

 

rpinxt
Impactful Individual
Impactful Individual

🤦‍

You are right...sorry about that!

Looks indeed to be working.

Thanks a lot!!

rpinxt
Impactful Individual
Impactful Individual

@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
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.