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
Ratax
Helper I
Helper I

Calculate number of days in use

hello

 

So i want DaysBetweenLoad to calculate the number of days between loads with regards to each system.

Take system 1 for example: The first Item is loaded the 01-12 which is the first so no days since last item was loaded. The next item on system 1 is loaded 03-12 which is 2 days after the first and so furth.

 

The rank should count what chronological order the item was loaded with regards to system and date.

So the item loaded on system 1 the 01-12 is the first, and the item loaded 03-12 is the second. 

 

ItemLoadedDateSystemIDDaysBetweenLastLoadRank with regards to date and system
55401-12-20201-1
44603-12-2020122
22506-12-20202-1
11205-12-20203-1
11408-12-2020134
66519-12-20202132
11312-12-2020372
88705-12-2020122

 

i hope this clarifies things

 

Best Regards

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

Hi , @Ratax 

Try calculated column as below:

DaysBetweenLastLoad = 
VAR Last_loadedDate =
    CALCULATE (
        MAX ( 'Table'[LoadedDate] ),
        'Table',
        'Table'[SystemID] = EARLIER ( 'Table'[SystemID] ),
        'Table'[LoadedDate] < EARLIER ( 'Table'[LoadedDate] )
    )
RETURN
    IF (
        ISBLANK ( Last_loadedDate ),
        BLANK (),
        DATEDIFF ( Last_loadedDate, 'Table'[LoadedDate], DAY )
    )
Rank with regards to date and system =
RANKX (
    FILTER ( 'Table', 'Table'[SystemID] = EARLIER ( 'Table'[SystemID] ) ),
    'Table'[LoadedDate],
    ,
    ASC,
    DENSE
)

 11.png

 

Please check sample file for more details.

 

Best Regards,
Community Support Team _ Eason
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-easonf-msft
Community Support
Community Support

Hi , @Ratax 

Try calculated column as below:

DaysBetweenLastLoad = 
VAR Last_loadedDate =
    CALCULATE (
        MAX ( 'Table'[LoadedDate] ),
        'Table',
        'Table'[SystemID] = EARLIER ( 'Table'[SystemID] ),
        'Table'[LoadedDate] < EARLIER ( 'Table'[LoadedDate] )
    )
RETURN
    IF (
        ISBLANK ( Last_loadedDate ),
        BLANK (),
        DATEDIFF ( Last_loadedDate, 'Table'[LoadedDate], DAY )
    )
Rank with regards to date and system =
RANKX (
    FILTER ( 'Table', 'Table'[SystemID] = EARLIER ( 'Table'[SystemID] ) ),
    'Table'[LoadedDate],
    ,
    ASC,
    DENSE
)

 11.png

 

Please check sample file for more details.

 

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

 

mahoneypat
Employee
Employee

If you want the number of days on which each item was used, you could just have a measure of

 

Days Used = DISTINCTCOUNT(Table[CreationDateTime])

 

If you want to know the span of days (first to last date), you could use

 

Days Used = DATEDIFF(MIN(Table[CreationDateTime]), MAX(Table[CreationDateTime]), DAY)

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


VijayP
Super User
Super User

@Ratax 

Question is not clear 

What is the definition of Item? is the system? if you could share some sample data with required result with that sample, solution will be much easier to know

Vijay Perepa




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


i updated the post, hope it helps

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.