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
sigtopo
Frequent Visitor

Average for mesure with date slicer

I have a dataset with the following:

  • id_sensor: sensor identifier
  • measurement_date: measurement date
  • data_value: value

I want to represent average values over a date range that the Powerbi dashboard user can select with a slicer.
I am in directQuery mode on a Postgresql database.
Is it possible ?

Here is a sample of data

id_sensormeasurement_datedata_value
1202402/06/2023 17:210.5
1202422/05/2023 17:020.25
1202423/05/2023 10:250.25
1202401/06/2023 16:580.5
1202415/05/2023 06:440
1202415/05/2023 17:040.5
1202416/05/2023 07:110.25
1202417/05/2023 07:160.25
1202419/05/2023 07:420
1202419/05/2023 17:181.25
1202420/05/2023 07:191
1202410/06/2023 16:260.5
1202411/06/2023 06:561.25
1202412/06/2023 14:501.25
1294622/05/2023 18:290.25
1294623/05/2023 06:190.25
1294603/06/2023 14:520.5
1294624/05/2023 13:490.25
1294605/06/2023 14:030.5
1294625/05/2023 15:520.5
1294606/06/2023 14:090.75
1294627/05/2023 15:081

....

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @sigtopo 

 

You can try the following methods. This formula can be run in Direct query mode.

Measure =
AVERAGEX ( FILTER ( 'Table',
        [measurement_date] >= MIN ( 'Table'[measurement_date] )
            && [measurement_date] <= MAX ( 'Table'[measurement_date] )
            && [id_sensor] = SELECTEDVALUE ( 'Table'[id_sensor] )
    ),
    [data_value]
)

vzhangti_0-1686810655155.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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
sigtopo
Frequent Visitor

It's perfect ! Thanks !

v-zhangti
Community Support
Community Support

Hi, @sigtopo 

 

You can try the following methods. This formula can be run in Direct query mode.

Measure =
AVERAGEX ( FILTER ( 'Table',
        [measurement_date] >= MIN ( 'Table'[measurement_date] )
            && [measurement_date] <= MAX ( 'Table'[measurement_date] )
            && [id_sensor] = SELECTEDVALUE ( 'Table'[id_sensor] )
    ),
    [data_value]
)

vzhangti_0-1686810655155.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

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.