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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
AliPoTD
Advocate II
Advocate II

Geomean with filter in a measure

Hello,

Can anyone please help?

I need a meaure which calculates the GEOMEAN average of a column for all rows with a date within the last 2 months of the slicer date, but I can't get it right. Can GEOMEAN be filtered in this way?

 

For example, TableA

DateValue
02/02/20248
03/03/20245
04/04/20246
05/05/20242

 

The user choses the date (Between) range of 1st May to 31st May from a slicer.

I want my measure to show the GEOMEAN average for all values from 2 months before, therefore from 1st April to 31st May

DateValue
04/04/20246
05/05/20242

 

I thought there was a stratightforward way of doing this but can't get the syntax right.

Any help greatly appreciated! Many thanks. 

1 ACCEPTED SOLUTION
AmiraBedh
Super User
Super User

Try this :

Measure_GEOMEAN_Last2Months = 
VAR MaxSlicerDate = MAX('TableA'[Date])
VAR MinSlicerDate = MIN('TableA'[Date])
VAR StartDate = DATE(YEAR(MinSlicerDate), MONTH(MinSlicerDate) - 2, DAY(MinSlicerDate))

RETURN
    GEOMEANX(
        FILTER(
            'TableA',
            'TableA'[Date] >= StartDate && 'TableA'[Date] <= MaxSlicerDate
        ),
        'TableA'[Value]
    )

 

AmiraBedh_0-1722110723352.png

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Why can't the user simply select April 1 - May 31 in the slicer.  As simple as it gets.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

🙂

 

Because the user will be selecting a single month to run an invoice e.g. May 2024.

Part of that invoice includes 2 calculations:

1) to get the Geomean average of data field A for the past 3 months

2) to get the Geomean average of data field B for the past 2 months

 

Kind regards,

AmiraBedh
Super User
Super User

Try this :

Measure_GEOMEAN_Last2Months = 
VAR MaxSlicerDate = MAX('TableA'[Date])
VAR MinSlicerDate = MIN('TableA'[Date])
VAR StartDate = DATE(YEAR(MinSlicerDate), MONTH(MinSlicerDate) - 2, DAY(MinSlicerDate))

RETURN
    GEOMEANX(
        FILTER(
            'TableA',
            'TableA'[Date] >= StartDate && 'TableA'[Date] <= MaxSlicerDate
        ),
        'TableA'[Value]
    )

 

AmiraBedh_0-1722110723352.png

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Hi,

 

Many thanks for this, it's really helpful.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors