Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Bash--
Frequent Visitor

Rolling days with reset

Hi All!

I have done the same calculation for rolling days (column) and my other columns are affecting the rolling 10 days calculation and not the correct value but if I deleted the column it gives me the right value. How to exclude columns in DAX without deleting them.

 

 

 

Column =
VAR __date = 'Table (2)'[Date]
VAR __allResource = ALLEXCEPT( 'Table (2)', 'Table (2)'[Resource] )
VAR __firstZero =
CALCULATE(
MAX( 'Table (2)'[Date]),
__allResource,
'Table (2)'[Date] <= __date,
'Table (2)'[Billable] = 0
)
VAR __start =
IF(
ISBLANK( __firstZero ),
CALCULATE(
MIN( 'Table (2)'[Date] ),
__allResource
),
__firstZero
)
RETURN
CALCULATE(
SUM( 'Table (2)'[Billable]),
FILTER(
ALL( 'Table (2)'[Billable]),
'Table (2)'[Date] >= __start && 'Table (2)'[Date] <= __date
)
)

 

 

WhatsApp Image 2022-02-01 at 7.46.39 PM (1).jpegWhatsApp Image 2022-02-01 at 7.46.39 PM.jpeg

 

Any Suggestions?

 

Thanks,

 

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @Bash-- ,

 

Your column seems to be wrong on my side. I have tried another method, please check if it helps:

 

Firstly, get the date of the nearest 0:

nearest0 = MINX(FILTER('Table (2)',[Resource]=EARLIER('Table (2)'[Resource]) && [Billable]=0 && [Date]>EARLIER('Table (2)'[Date])),[Date])

Get the rolling sum:

Result = CALCULATE(SUM('Table (2)'[Billable]),FILTER('Table (2)',[Resource]=EARLIER('Table (2)'[Resource]) && [nearest0]=EARLIER('Table (2)'[nearest0])  && [Date]<=EARLIER('Table (2)'[Date])))

 Output:

Eyelyn9_0-1644288096264.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-eqin-msft
Community Support
Community Support

Hi @Bash-- ,

 

Your column seems to be wrong on my side. I have tried another method, please check if it helps:

 

Firstly, get the date of the nearest 0:

nearest0 = MINX(FILTER('Table (2)',[Resource]=EARLIER('Table (2)'[Resource]) && [Billable]=0 && [Date]>EARLIER('Table (2)'[Date])),[Date])

Get the rolling sum:

Result = CALCULATE(SUM('Table (2)'[Billable]),FILTER('Table (2)',[Resource]=EARLIER('Table (2)'[Resource]) && [nearest0]=EARLIER('Table (2)'[nearest0])  && [Date]<=EARLIER('Table (2)'[Date])))

 Output:

Eyelyn9_0-1644288096264.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Bash--
Frequent Visitor

@parry2k Hi. Thanks for the quick reply. I tried to but date column returns grey and not available for measure 

parry2k
Super User
Super User

@Bash-- without looking at the details, you should be adding this as a measure not a column

 

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

 

Check my latest video on Filters and Sparklines https://youtu.be/wmwcX8HvNxc

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



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.

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.