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
Anonymous
Not applicable

Filter data and subtract

Hi comunity, 

 

I've been working on power BI for some time now, and I like it very much, I have a problem with a function, maybe you can help me, I want to know the difference per user of the use dsize  between the last two dates. El resultado lo muestre en otra tabla, con el nombre de usuario y la diferencia

 

I appreciate your help.

 

1.JPG

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

HI @Anonymous,

 

I try to extract datetime string from your source name column, but I found some records contains incorrect time value.

 

Calculate column formula:

DateTime characters = 
VAR trimSpace =
    SUBSTITUTE ( UPPER ( [Source.Name] ), " ", "" )
VAR removeUnder =
    SUBSTITUTE ( trimSpace, "_", "" )
RETURN
    PATHITEM ( SUBSTITUTE ( removeUnder, "LOCAL", "|" ), 1 )

10.PNG

 

I'd like to know last four characters means time value or just id? If it means time value, please share some correct sampel data here for test.

 

Sample:

Use calculated column to get date value from above text.

Date = 
VAR _date =
    LEFT ( [DateTime characters], 8 )
VAR _year =
    LEFT ( _date, 4 )
VAR _month =
    RIGHT ( LEFT ( _date, 6 ), 2 )
VAR _day =
    RIGHT ( _date, 2 )
RETURN
    DATE ( _year, _month, _day )

Measure of diff between previous and current:

Diff of previous = 
VAR previous =
    MAXX (
        FILTER (
            ALL ( 'sample' ),
            [Users] = SELECTEDVALUE ( 'sample'[Users] )
                && [Date] < MAX ( 'sample'[Date] )
        ),
        [Date]
    )
RETURN
    IF (
        previous <> BLANK (),
        DATEDIFF ( previous, MAX ( 'sample'[Date] ), DAY ),
        0
    )

Result:

11.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

HI @Anonymous,

 

I try to extract datetime string from your source name column, but I found some records contains incorrect time value.

 

Calculate column formula:

DateTime characters = 
VAR trimSpace =
    SUBSTITUTE ( UPPER ( [Source.Name] ), " ", "" )
VAR removeUnder =
    SUBSTITUTE ( trimSpace, "_", "" )
RETURN
    PATHITEM ( SUBSTITUTE ( removeUnder, "LOCAL", "|" ), 1 )

10.PNG

 

I'd like to know last four characters means time value or just id? If it means time value, please share some correct sampel data here for test.

 

Sample:

Use calculated column to get date value from above text.

Date = 
VAR _date =
    LEFT ( [DateTime characters], 8 )
VAR _year =
    LEFT ( _date, 4 )
VAR _month =
    RIGHT ( LEFT ( _date, 6 ), 2 )
VAR _day =
    RIGHT ( _date, 2 )
RETURN
    DATE ( _year, _month, _day )

Measure of diff between previous and current:

Diff of previous = 
VAR previous =
    MAXX (
        FILTER (
            ALL ( 'sample' ),
            [Users] = SELECTEDVALUE ( 'sample'[Users] )
                && [Date] < MAX ( 'sample'[Date] )
        ),
        [Date]
    )
RETURN
    IF (
        previous <> BLANK (),
        DATEDIFF ( previous, MAX ( 'sample'[Date] ), DAY ),
        0
    )

Result:

11.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

Hi

 

Thank you for your answer. The difference is for the "Used Size (MB)" column only for the two most recent dates, no time is required. 

 

 

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.