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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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