Forum Discussion
Read previous rows from dates
- 6 years ago
Try this
Column = VAR _PreviousDay = MAXX ( FILTER ( MyTable, MyTable[Date] < EARLIER ( MyTable[Date] ) && MyTable[Status] <> "OFF" ), MyTable[Date] ) VAR _result = SUMX ( FILTER ( MyTable, MyTable[Date] < EARLIER ( MyTable[Date] ) && MyTable[Date] >= _PreviousDay ), MyTable[Cost] ) RETURN _result
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂
| Date | Day | Status |
| 19-05-2020 | Tuesday | |
| 20-05-2020 | Wednesday | |
| 21-05-2020 | Thursday | |
| 22-05-2020 | Friday | |
| 23-05-2020 | Saturday | OFF |
| 24-05-2020 | Sunday | OFF |
| 25-05-2020 | Monday | OFF |
| 26-05-2020 | Tuesday | OFF |
| 27-05-2020 | Wednesday | |
| 28-05-2020 | Thursday | |
| 29-05-2020 | Friday | |
| 30-05-2020 | Saturday | OFF |
| 31-05-2020 | Sunday | OFF |
| 01-06-2020 | Monday | |
| 02-06-2020 | Tuesday | |
| 03-06-2020 | Wednesday | |
| 04-06-2020 | Thursday |
Create a calculated column
Previous Working Day = MAXX(FILTER(MyTable,MyTable[Date]<EARLIER(MyTable[Date])&&MyTable[Status]<>"OFF"),MyTable[Date])
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂
A vey good solution! But what i mean is if the date is 1/6/2020 (monday), and we have 2 days off, we will take the data that add from date 29-31 May 2020. How to handle with it ?
nandukrishnavs
amitchandak
- nandukrishnavs6 years agoCommunity Champion
New_be did you check my original post?
- New_be6 years agoHelper V
nandukrishnavs i do check your solution and it is awesome! But i think i wrongly asked before. Pardon for that. My question is how can i get previous data like in this image that i draw. For example, if the date 27/5/2020 (wednesday) and we have 4 days off from 23-26 May 2020, then i want to take the data from before the last date off that is from 22-26 May 2020. And then the value for 27/5/2020 (wed) will b e the sum of cost from22-26 May 2020.
I dont know whether it is possible to do that in power bi, but i hope with your help, i can learn something new 🤗- nandukrishnavs6 years agoCommunity Champion
Try this
Column = VAR _PreviousDay = MAXX ( FILTER ( MyTable, MyTable[Date] < EARLIER ( MyTable[Date] ) && MyTable[Status] <> "OFF" ), MyTable[Date] ) VAR _result = SUMX ( FILTER ( MyTable, MyTable[Date] < EARLIER ( MyTable[Date] ) && MyTable[Date] >= _PreviousDay ), MyTable[Cost] ) RETURN _result
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂