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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
cheid_4838
Helper IV
Helper IV

Sum Values Every Nth Day

I created the below table that shows tractors, distance traveled each day and various fuel totals. I would like to to create a column that will show the distance traveled every 2 or 3 days for each tractor. I want to compare that total to the Total Miles (Full) column to decide whether fuel stops could be eliminated.  Is there an easy way to sum the distance every 2 or 3 days?  Thanks.

 

 

 

cheid_4838_0-1750701377402.png

 

6 REPLIES 6
v-pnaroju-msft
Community Support
Community Support

Hi cheid_4838,

We have not received a response from you regarding the query and were following up to check if you have found a resolution. If you have identified a solution, we kindly request you to share it with the community, as it may be helpful to others facing a similar issue.

If you find the response helpful, please mark it as the accepted solution, as this will help other members with similar queries.

Thank you.

v-pnaroju-msft
Community Support
Community Support

Thankyou, @jgeddes@Ashish_Mathur, for your response.

Hi cheid_4838,

We sincerely appreciate your inquiry submitted through the Microsoft Fabric Community Forum.

Based on my understanding of the issue, please find attached a screenshot along with a sample pbix file, which may assist in resolving the matter:

vpnarojumsft_0-1750757152561.png

If you find our response helpful, kindly consider marking it as the accepted solution and provide kudos. This will aid other community members encountering similar queries.

If the response does not fully address your requirements, we kindly request you to provide sample data that clearly illustrates your issue or question in a usable format (not as a screenshot). Please ensure that the data does not contain any sensitive information or unrelated content. Additionally, please specify the expected outcome based on the sample data provided.

Should you have any further queries, please do not hesitate to reach out to the Microsoft Fabric community.

Thank you.

jgeddes
Super User
Super User

Using DATESINPERIOD in a CALCULATE function may work for you. As an example...

Last X Days = 
CALCULATE(
    SUM('Table'[Distance]),
    DATESINPERIOD('Table'[Date], SELECTEDVALUE('Table'[Date]), -2, DAY)
)

You could also use a parameter to dynamically set the number of days if you wanted to switch between 2 or 3. (Or any number you want.)





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





That did not work.  Regardless of the number I enter the logic does not sum and the value is the same for each date.

 

cheid_4838_0-1750703394745.png

 

Hi,

Share some data to work with and show the expected result.  Share data in a format that can be pasted in an MS Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

I should have mentioned that if you are using a date table in your model you will need to ensure that the dates referenced in the measure align with the dates used in the visualization, which can vary if you are using a date model.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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