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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
rjsidek
Helper II
Helper II

Getting Average based on Latest entry

Hi everyone,

I have a dataset that looks like this

 

Question for average.pngWhat I am trying to do is create a measure in PowerBI to get the Average Deal Size for a company. Basically taking Deal Size min+ deal size max and dividing by 2. However, note that there are multiple entries in the deal size columns, meaning that these deal sizes change over time. I want to create an average measure that takes the latest entries by date. It gets more complicated because there might e circumstances where only one of the deal size comuns are filled ie. there is a value in deal size max but none in deal size min.

 

Is there a measure I can use to solve this issue? Have been tring to crack this for days now. Please help if you can.

 

@amitchandak @parry2k 

7 REPLIES 7
amitchandak
Super User
Super User

Try, Some thing like

 

Total = Calculate(
    sumx(   
            SUMMARIZE(
                data,
                data[company],
				data[geography],
				"_Min",
				minx( filter(data,data[Deal Size(min)]>0,data[date])),
                "_Max"
				minx( filter(data,data[Deal Size(max)]>0,data[date])),
				"_comp"
				max(data[company]),
				"_geo"
				max(data[geography])
            ),
            calculate(
                divide(_Min+_Max,(if(isblank(_Max),0,1)+if(isblank(_Min),0,1)))
                
            
    )
)

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak 

 

Have tried implementing the code you suggested, but I got an error. Below is a screenshot:

 

Follow up Amit.png

 Any ideas on how to rectify this?

 

 

put _min and _max in [ ]

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak 

 

Is this for the bottom line after the "Divide" function? I put them in [ ] like so

 

divide([_Min]+[_Max],(if(isblank[_Max]),0,1)+if(isblank([_Min]),0,1)))

 but am still receiving the same errors 

Link : https://www.dropbox.com/s/nhqat3sfzupt3yc/dealsize.pbix?dl=0

formula : you might have to change as per need

Total = Calculate(
    sumx(   
            SUMMARIZE(
                data,
                data[company],
				data[geography],
				"_Min",
				minx( filter(data,data[Deal Size(min)]>0),data[date]),
                "_Max",
				minx(filter(data,data[Deal Size(max)]>0),data[date]),
				"_comp",
				max(data[company]),
				"_geo",
				max(data[geography])
            ),
            divide(minx(filter(data,data[company]=[_comp] && data[geography]=[_geo] && data[date]= [_Min]),data[Deal Size(min)])+maxx(filter(data,data[company]=[_comp] && data[geography]=[_geo] && data[date]= [_Max]),data[Deal Size(max)] ),(if(isblank([_Max]),0,1)+if(isblank([_Min]),0,1)))
                
            
    )
)

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak ,

 

Thanks for the pbi file. I looked at it and it seems correct. However, instead of calculating the average for each column, is there a way for it to only take the average based on latest entries of deal size max and min? Right now it seems like it is taking the average for every row instead of only the latest one

Check it like second table. Should now be there in link.

Now instead of sumx , you might want averagex for GT.

Screenshot 2020-01-14 12.38.32.png

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors