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

Show the Daily Difference for Each Item

I've looked at other solutions here and none seem to be doing the trick. 

DateTimeItemValue
Dec 1 9AMA1
Dec 1 10AMB3
Dec 2 9AMB4
Dec 2 11AMB5
Dec 3 12PMA4

 

So there's a few things going on here, but essentially, I need to show a graph that shows how much each Item has increased for each day. 

In this case, a clustered graph would show:
- Dec 1: 0 for Items A and B (as there's no previous date to report an increase from)
- Dec 2: 0 for A (as there are no entries for Item A for Dec 2) and 2 for Item B ( ([Dec 1 for B] = 3) minus ([last entry for Dec 2] = 5) = 2).
- Dec 3: 3 for A, and 0 for B using the same logic. 

Let me know if you need any more details, but this seems extremely difficult given the research and solutions I've already tried.

 

Thank you VERY much!

Edit: This was poorly worded, so I tried to clean it up.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but please check the below picture and the attached pbix file.

I tried to create date only column and time only column in order to show a visualization like below.

 

Jihwan_Kim_0-1674477802956.png

 

Expected result measure: =
VAR _currentlastvalue =
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[Time] = MAX ( 'Table'[Time] ) )
VAR _prevlasttime =
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Item] = MAX ( 'Table'[Item] )
                && 'Table'[Date] < MAX ( 'Table'[Date] )
        ),
        'Table'[Time]
    )
VAR _prevlastvalue =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Item] = MAX ( 'Table'[Item] )
                && 'Table'[Date] < MAX ( 'Table'[Date] )
                && 'Table'[Time] = _prevlasttime
        )
    )
RETURN
    IF (
        ISINSCOPE ( 'Table'[Date] ) && ISINSCOPE ( 'Table'[Item] ),
        SWITCH (
            TRUE (),
            _prevlastvalue <> BLANK (), _currentlastvalue - _prevlastvalue,
            _prevlastvalue = BLANK (), 0
        )
    )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Wow! This works! Thank you for this!

There is one extra problem. I've got thousands of entries between December 22 and January 22 (31 days). So my graph is cramped and tiny. How can I make it so that it shows the results for the day, as well as the hour?

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but please check the below picture and the attached pbix file.

I tried to create date only column and time only column in order to show a visualization like below.

 

Jihwan_Kim_0-1674477802956.png

 

Expected result measure: =
VAR _currentlastvalue =
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[Time] = MAX ( 'Table'[Time] ) )
VAR _prevlasttime =
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Item] = MAX ( 'Table'[Item] )
                && 'Table'[Date] < MAX ( 'Table'[Date] )
        ),
        'Table'[Time]
    )
VAR _prevlastvalue =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Item] = MAX ( 'Table'[Item] )
                && 'Table'[Date] < MAX ( 'Table'[Date] )
                && 'Table'[Time] = _prevlasttime
        )
    )
RETURN
    IF (
        ISINSCOPE ( 'Table'[Date] ) && ISINSCOPE ( 'Table'[Item] ),
        SWITCH (
            TRUE (),
            _prevlastvalue <> BLANK (), _currentlastvalue - _prevlastvalue,
            _prevlastvalue = BLANK (), 0
        )
    )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


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.

Top Solution Authors