The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I've looked at other solutions here and none seem to be doing the trick.
DateTime | Item | Value |
Dec 1 9AM | A | 1 |
Dec 1 10AM | B | 3 |
Dec 2 9AM | B | 4 |
Dec 2 11AM | B | 5 |
Dec 3 12PM | A | 4 |
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.
Solved! Go to Solution.
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.
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
)
)
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?
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.
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
)
)
User | Count |
---|---|
10 | |
9 | |
6 | |
6 | |
5 |
User | Count |
---|---|
21 | |
14 | |
14 | |
9 | |
7 |