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
DimaMD
Solution Sage
Solution Sage

Amount of refuel in trip

Hello community!

 

I need your help in correct count of amount of fuel in my table.

 

We have following data:

1)Name of Vehicle

2) Date of operation

3) Type of operation

4) Refueling point

5) Amount of refueled 

6) Start/end of trip

7) Result (as wanted)

 

We are interested in counting the amount of fuel which was refueled in points, which are not blank and not equal to "Base"

 

For example we have a trip which starts on 04.07.2022 and end's on 12.07.2022, so we have 2 rows which are not blank and not equal "Base". Result should be 198,08+16,07= 214,15 (as shown in "Result" collum)

 

The result of this count must be saved in cell of collum "Amount of refueled", which row is marked as "End" in "Start/end of trip" collum (in current table you can see "0" in that cell)

 

As an example, the trip dated as 12.07.2022 must have result 214,15 in "ammount of refueled" cell in row which marked as "End"


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @DimaMD,

You can try to use the following measure formula to get the start/end period based on current date, then you can summary records include in this range except the base point:

formula =
VAR currdate =
    MAX ( 'Export'[Data] )
VAR _start =
    CALCULATE (
        MAX ( 'Export'[Data] ),
        FILTER (
            ALLSELECTED ( 'Export' ),
            [Start/end of trip] = "start"
                && [Data] <= currdate
        )
    )
VAR _end =
    CALCULATE (
        MIN ( 'Export'[Data] ),
        FILTER (
            ALLSELECTED ( 'Export' ),
            [Start/end of trip] = "End"
                && [Data] >= currdate
        )
    )
RETURN
    CALCULATE (
        SUM ( 'Export'[Refueled] ),
        FILTER (
            ALLSELECTED ( 'Export' ),
            [Data] >= _start
                && [Data] <= _end
                && [Refueling point] <> "Base"
        )
    )

1.PNG

Regards,

Xiaoxin Sheng

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @DimaMD,

You can try to use the following measure formula to get the start/end period based on current date, then you can summary records include in this range except the base point:

formula =
VAR currdate =
    MAX ( 'Export'[Data] )
VAR _start =
    CALCULATE (
        MAX ( 'Export'[Data] ),
        FILTER (
            ALLSELECTED ( 'Export' ),
            [Start/end of trip] = "start"
                && [Data] <= currdate
        )
    )
VAR _end =
    CALCULATE (
        MIN ( 'Export'[Data] ),
        FILTER (
            ALLSELECTED ( 'Export' ),
            [Start/end of trip] = "End"
                && [Data] >= currdate
        )
    )
RETURN
    CALCULATE (
        SUM ( 'Export'[Refueled] ),
        FILTER (
            ALLSELECTED ( 'Export' ),
            [Data] >= _start
                && [Data] <= _end
                && [Refueling point] <> "Base"
        )
    )

1.PNG

Regards,

Xiaoxin Sheng

Hi? @Anonymous  Thank you, the measure works correctly


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com

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.