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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Ibrahim_shaik
Helper V
Helper V

Dax Measure to Calculate the value from a specific column depending on the temperature Column

Hi Power BI Community,

 

I have a Table in which there are three columns with the consumption values and a temperature column.

 

I need to calculate the consumption depending on the temperature.

 

Example: In two hour 11 AM to 1 PM consumption the temperature from 11 AM to 12 PM might be below 35 degree and from 12 PM to 1 PM it might be above 40 degree.

 

So I want to calculate the consumption depending on temp for the Selected time period may be 1 hour or 2 hour, 1 day, one week, month, year.

 

tons_temp.png

 

Please give a Solution.

 

Thanks&Regards,

Ibrahim.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Ibrahim_shaik ,

Based on the information you provided, I have created a sample data to solve your problem and you can follow the steps below:
1. Add an index column.

vyifanwmsft_0-1710828730320.png


2. Add a calculated column that calculates the difference in time.

hour = 
VAR _index = 'Table'[Index]
VAR _1 =
    CALCULATE (
        MAX ( 'Table'[Time] ),
        FILTER ( 'Table', 'Table'[Index] = _index - 1 )
    )
VAR _hour =
    DATEDIFF ( 'Table'[Time], _1, HOUR )
RETURN
    _hour


3. Add a measure that calculates the loss when the time is one hour apart.

hour Consumption = 
CALCULATE (
    SUM ( 'Table'[consumption] ),
    FILTER ( 'Table', 'Table'[hour] = -1 )
)

 

Final output:

vyifanwmsft_1-1710828809022.png

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

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

2 REPLIES 2
Anonymous
Not applicable

Hi @Ibrahim_shaik ,

Based on the information you provided, I have created a sample data to solve your problem and you can follow the steps below:
1. Add an index column.

vyifanwmsft_0-1710828730320.png


2. Add a calculated column that calculates the difference in time.

hour = 
VAR _index = 'Table'[Index]
VAR _1 =
    CALCULATE (
        MAX ( 'Table'[Time] ),
        FILTER ( 'Table', 'Table'[Index] = _index - 1 )
    )
VAR _hour =
    DATEDIFF ( 'Table'[Time], _1, HOUR )
RETURN
    _hour


3. Add a measure that calculates the loss when the time is one hour apart.

hour Consumption = 
CALCULATE (
    SUM ( 'Table'[consumption] ),
    FILTER ( 'Table', 'Table'[hour] = -1 )
)

 

Final output:

vyifanwmsft_1-1710828809022.png

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

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

lbendlin
Super User
Super User

You would usually use a scatter plot for this.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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