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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors