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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
sigtopo
Regular 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
Regular 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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors