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
Anonymous
Not applicable

Average with IF statement

Hi,

 

I have a measure to calculate an average of values by year. Is it possible include a condition in this formula so that the very first non-zero yearly value in my data is divided by 12 (months) to get an accurate yearly average.

 

Thanks in advance. 

3 REPLIES 3
Nathaniel_C
Community Champion
Community Champion

Hi @Anonymous ,

Would you give us a little more detail? Is there a condition that could be used to signify the first non zero value? Could I say "IF the row before this is zero then divide by 12?
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

@Nathaniel_C ,

 

The data is for oil and gas production and the way our database is set up means that all fields start producing from the year 1960 and extend to 2060, with many zero's at the beginning and end for many of the fields.

 

As for your question - there are also zero values throughout the data so it is only the very first non-zero value that I would like to divide by 12. All other values will be averaged by the number of months of production, which is working as expected. 

 

So rather than "IF the row before this is zero then divide by 12" I need something along the lines of "IF the first value <> 0 then divide by 12, otherwise average by the number of production months".

 

Thanks

Anonymous
Not applicable

@Nathaniel_C 

 

So I have figured that I need a flagging calculated column to mark the First Occurence of the non-zero value. 

 

How do I now write the measure to say something along the lines of "IF First Occurance = Yes then divide by 12, else average"

 

Thanks

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.