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

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.

Reply
Big_Trucks
Frequent Visitor

Adjust for usage

Hi All,

 

I could really use some help on this line graph I am attempting to build. The idea is based on a service plan for a vehicle using milage as the input variable. Depending on how much the truck is driven determines it service schedule which is fixed at milage intervals, and the dollars spent over the life of the service plan. If a given truck is estimated to drive 100 miles a month, I have an outlined service plan in blue below. If the truck is driven less than expected (or more), I want to shift the graph from today to account for the lower(or higher) number of miles driven over the last 3 month avg (say 80 miles). How would I be able to make sure the starting point stays the same, and just shift the graph over today as indicated in red to account for the adjustment?

 

Also to note, my dollars are accounted for in a measure. I do not want to bring in all the leading zero values from my date table as you can see. 

 

graph-shift2.jpg

graph-shift.jpg

 

graph-shift5.jpg

If further info is needed feel free to ask. 

 

P.S. I added the data as requested. You can see how the actual run miles happened later than projected in time. Thus would shift the time schedule of the service milestones.

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

HI @Big_Trucks,

What type of value are you stored in date fields? If they are date values, you can create an unconnected table(it does not have relationships to the raw table) with date value as a selector to choose when the graph started.

Measure =
VAR selected =
    MAX ( selector[Date] )
VAR currDate =
    MAX ( table[Actual Year QTR] )
VAR rolling =
    CALCULATE (
        SUM ( table[Milage Actual] ),
        FILTER (
            ALLSELECTED ( table ),
            [Actual Year QTR] >= selected
                && [Actual Year QTR] <= currDate
        )
    )
RETURN
    CALCULATE (
        SUM ( 'service'[Expense] ),
        FILTER (
            ALLSELECTED ( 'service' ),
            [service milestones]
                <= INT ( rolling / 100 ) * 100
        )
    )

Notice: you can use the 'Actual mile' record table data field as the axis of the visual. 
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

HI @Big_Trucks,

What type of value are you stored in date fields? If they are date values, you can create an unconnected table(it does not have relationships to the raw table) with date value as a selector to choose when the graph started.

Measure =
VAR selected =
    MAX ( selector[Date] )
VAR currDate =
    MAX ( table[Actual Year QTR] )
VAR rolling =
    CALCULATE (
        SUM ( table[Milage Actual] ),
        FILTER (
            ALLSELECTED ( table ),
            [Actual Year QTR] >= selected
                && [Actual Year QTR] <= currDate
        )
    )
RETURN
    CALCULATE (
        SUM ( 'service'[Expense] ),
        FILTER (
            ALLSELECTED ( 'service' ),
            [service milestones]
                <= INT ( rolling / 100 ) * 100
        )
    )

Notice: you can use the 'Actual mile' record table data field as the axis of the visual. 
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
parry2k
Super User
Super User

@Big_Trucks I would recommend to provide sample data and expected output,  you can put together something in excel.



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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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