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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Jasel
Helper II
Helper II

Average from value above and below

Howdy all!

 

I have a set of data that is not fully complete.  Here is an example:

 

DateTMAXTMIN
193805307360
193805318053
1938060181-9999
193806027563

 

The -9999 shows the incomple data.

 

Is there a way to check for values above or below in the calumn to figure out an avereage if the above and below values are not -9999?  This is my main ask.

 

Secondary ask is the only other thing I figure I could do is replace the -9999 with blank or null, but not sure how to do that either since the replace function requires a number value to replace with.  I'm sure I can create anohter column where if the value is -9999 than blank in DAX but that seems messy to me since I have quite a few columns with this issue.

1 ACCEPTED SOLUTION
Phil_Seamark
Employee
Employee

Hi @Jasel,

 

This would be easier if you have an index column to help determin the rows before/after.

 

The Query Editor can possibly help with this, allthough you'll have to check your sorting.

 

Index.png

 

Then if you create a calculated table like this you can build simple AVERAGE measures over it

 

 

Table = SELECTCOLUMNS(
    FILTER(
        CROSSJOIN ('Table1',SELECTCOLUMNS('Table1',"ID2",[Index],"TMAX2",[TMAX],"TMIN2",[TMIN])),
        [Index]>=[ID2]-1 
        && [Index] <= [ID2]+1 
        && [TMIN2] <> -9999
        ),"Date" , [Date] , "TMIN" , [TMIN2] , "TMAX" , [TMAX2])

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

1 REPLY 1
Phil_Seamark
Employee
Employee

Hi @Jasel,

 

This would be easier if you have an index column to help determin the rows before/after.

 

The Query Editor can possibly help with this, allthough you'll have to check your sorting.

 

Index.png

 

Then if you create a calculated table like this you can build simple AVERAGE measures over it

 

 

Table = SELECTCOLUMNS(
    FILTER(
        CROSSJOIN ('Table1',SELECTCOLUMNS('Table1',"ID2",[Index],"TMAX2",[TMAX],"TMIN2",[TMIN])),
        [Index]>=[ID2]-1 
        && [Index] <= [ID2]+1 
        && [TMIN2] <> -9999
        ),"Date" , [Date] , "TMIN" , [TMIN2] , "TMAX" , [TMAX2])

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.