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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.