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.
I want to get the difference between the successive rows in a column(Confirmed_cases). I have indexed the columns by category but can't go further. Please help.
Solved! Go to Solution.
@Newbie992 try this
Diff =
VAR __index = SELECTEDVALUE ( 'Table'[Index] )
VAR __prevIndex = __index - 1
VAR __prevValue =
CALCULATE (
SUM ( 'Table'[Confirmed_cases] ),
ALLEXCEPT ( 'Table', 'Table'[Location_Key] ),
'Table'[Index] = __prevIndex
)
RETURN
SUM ( 'Table'[Confirmed_cases] ) - __prevValue
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@Newbie992 try this measure
Diff =
VAR __index = SELECTEDVALUE ( Table[Index )
VAR __prevIndex = __index - 1
VAR __country = SELECTEDVALUE Table[Country] )
VAR __prevValue = CALULATE ( SUM ( Table[Cases] ), Table[Index] = __prevIndex, Table[Country] = __country )
RETURN
SUM ( Table[Cases] ) - __prevValue
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi,
Thanks for your reply!
It's not working for me. In the result, I get the same values that are in Confirmed_cases column. I checked and in the variable _prevValue I am not getting any values.
Thanks!
@Newbie992 do you getting value in the _index variable. Can you paste data in a table format so that I can copy it? I probably missed something, I pasted the expression from my phone and was a bit hard to type.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi @parry2k ,
Yes I see data in __index variable but not in __prevValue.
Here is a sample of my data:
Location_Key | New_Cases_Date | Confirmed_cases | Index |
Afghanistan | 2020-04-19 00:00:00 | 996 | 1 |
Afghanistan | 2020-04-20 00:00:00 | 1026 | 2 |
Afghanistan | 2020-04-21 00:00:00 | 1092 | 3 |
Afghanistan | 2020-04-22 00:00:00 | 1176 | 4 |
Afghanistan | 2020-04-23 00:00:00 | 1279 | 5 |
Afghanistan | 2020-04-24 00:00:00 | 1351 | 6 |
Albania | 2020-03-09 00:00:00 | 2 | 1 |
Albania | 2020-03-10 00:00:00 | 10 | 2 |
Albania | 2020-03-11 00:00:00 | 12 | 3 |
Albania | 2020-03-12 00:00:00 | 23 | 4 |
Thanks!
@Newbie992 try this
Diff =
VAR __index = SELECTEDVALUE ( 'Table'[Index] )
VAR __prevIndex = __index - 1
VAR __prevValue =
CALCULATE (
SUM ( 'Table'[Confirmed_cases] ),
ALLEXCEPT ( 'Table', 'Table'[Location_Key] ),
'Table'[Index] = __prevIndex
)
RETURN
SUM ( 'Table'[Confirmed_cases] ) - __prevValue
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |