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.
The following formula shows the difference between 1 row and the last. I spent a long time working on this and needed the help of someone here to get it to this point. But the result is showing the difference PER ENTRY, while I am looking for PER DAY and PER HOUR.
BPS =
VAR _currentlastvalue =
CALCULATE ( SUM ( 'Table'[Value]), 'Table'[Date] = MAX ( 'Table'[Date] ) )
VAR _prevlasttime =
MAXX (
FILTER (
ALL ( 'Table' ),
'Table'[Item] = MAX ( 'Table'[Item])
&& 'Table'[Date] < MAX ( 'Table'[Date] )
),
'Table'[Date]
)
VAR _prevlastvalue =
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALL ( 'Table'),
'Table'[Item] = MAX ( 'Table'[Item] )
&& 'Table'[Date] < MAX ( 'Table'[Date] )
&& 'Table'[Date] = _prevlasttime
)
)
RETURN
IF (
ISINSCOPE ( 'Table'[Date] ) && ISINSCOPE ( 'Table'[Item] ),
SWITCH (
TRUE (),
_prevlastvalue <> BLANK (), _currentlastvalue - _prevlastvalue,
_prevlastvalue = BLANK (), 0
)
)
So I believe a Summarize function is needed to group this measure into days and hours. Perhaps I'll need 2 separate measures, which is fine.
Thank you!
Hi @Anonymous ,
What does your raw data look like?
Sorry for that the information you have provided is not making the problem clear to me. Can you please share more details to help us clarify your scenario?
Please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.
Refer to:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
11 | |
8 | |
6 | |
6 | |
6 |
User | Count |
---|---|
24 | |
14 | |
13 | |
9 | |
8 |