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
christobal96
New Member

Monthly consumption of meters

Hello, 

 

I would like to calcultate consumption of differents meters using their monthly index. 

 

An exemple of the raw data would be: 

MetersDateindex
Cpt101/03/201512
Cpt201/03/201524
Cpt101/04/201518
Cpt201/04/201532
Cpt101/05/201522
Cpt201/05/201539

 

And the result, i'm expecting is: 

MetersDateConsumption
Cpt101/03/20156
Cpt101/04/20154
Cpt201/03/20158
Cpt201/04/2015

7

 

The Consumption is the difference between 2 index of consecutive months.

I hope, this is clear enough. 

 

Thanks you by advance for help.

 

1 ACCEPTED SOLUTION

Thanks a lot for this answer. 

 

There was just a little change I had to do so it's work on my computer: 

Instead of 

 = MAX ( 'Monthly consumption'[Date] ) + 1

 

Which incremente the day, I had to write:

 

= DATE(YEAR(MAX ( 'Monthly consumption'[Date] ));MONTH(MAX ( 'Monthly consumption'[Date] ))+1;1)

 

So the final measure formula is: 

 

consumption =
IF (
MAX ( 'Monthly consumption'[Date] )
= MAXX (
ALLEXCEPT ( 'Monthly consumption'; 'Monthly consumption'[Meters] );
'Monthly consumption'[Date]
);
BLANK ();
CALCULATE (
MAX ( 'Monthly consumption'[index] );
FILTER (
ALLEXCEPT ( 'Monthly consumption'; 'Monthly consumption'[Meters] );
'Monthly consumption'[Date]
= DATE(YEAR(MAX ( 'Monthly consumption'[Date] ));MONTH(MAX ( 'Monthly consumption'[Date] ))+1;1)
)
)
- MAX ( 'Monthly consumption'[index] )
)

 

Thanks you Yuliana Gu !

 

 

View solution in original post

3 REPLIES 3
v-yulgu-msft
Employee
Employee

Hi @christobal96,

 

Suppose the original table is called 'Monthly consumption', you could create a measure like below:

consumption =
IF (
    MAX ( 'Monthly consumption'[Date] )
        = MAXX (
            ALLEXCEPT ( 'Monthly consumption', 'Monthly consumption'[Meters] ),
            'Monthly consumption'[Date]
        ),
    BLANK (),
    CALCULATE (
        MAX ( 'Monthly consumption'[index] ),
        FILTER (
            ALLEXCEPT ( 'Monthly consumption', 'Monthly consumption'[Meters] ),
            'Monthly consumption'[Date]
                = MAX ( 'Monthly consumption'[Date] ) + 1
        )
    )
        - MAX ( 'Monthly consumption'[index] )
)

Add this measure into a Table visual.

1.PNG

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hello,

 

How can I do that in the query editor?

What steps do I have to take to get the same result.

I tried the steps below but it didn't work.

I made two columns year and month based on date (1 date each month)

I made two columns min() and max() based on the meter value.

Grouped by Year and kind of meteringpoint

Subtract min() and max()

 

Kind regards,

Mark

Thanks a lot for this answer. 

 

There was just a little change I had to do so it's work on my computer: 

Instead of 

 = MAX ( 'Monthly consumption'[Date] ) + 1

 

Which incremente the day, I had to write:

 

= DATE(YEAR(MAX ( 'Monthly consumption'[Date] ));MONTH(MAX ( 'Monthly consumption'[Date] ))+1;1)

 

So the final measure formula is: 

 

consumption =
IF (
MAX ( 'Monthly consumption'[Date] )
= MAXX (
ALLEXCEPT ( 'Monthly consumption'; 'Monthly consumption'[Meters] );
'Monthly consumption'[Date]
);
BLANK ();
CALCULATE (
MAX ( 'Monthly consumption'[index] );
FILTER (
ALLEXCEPT ( 'Monthly consumption'; 'Monthly consumption'[Meters] );
'Monthly consumption'[Date]
= DATE(YEAR(MAX ( 'Monthly consumption'[Date] ));MONTH(MAX ( 'Monthly consumption'[Date] ))+1;1)
)
)
- MAX ( 'Monthly consumption'[index] )
)

 

Thanks you Yuliana Gu !

 

 

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.