+ Reply to Thread
Results 1 to 5 of 5

Filtering out zeros and blanks

  1. #1
    Registered User
    Join Date
    07-15-2013
    Location
    Denver,CO
    MS-Off Ver
    Excel 2010
    Posts
    9

    Filtering out zeros and blanks

    I am a new user to powerpivot and dax expressions. I am trying to figure out why this returns an error. I want this to return a table that is my [Oil rate] column from my 'Source Data' but filtering out anything that is blank or zero.
    I think this should just filter out the zeros, but this returns an error. Is this not doing what I think it should be doing? Also how do I add the no blanks to this?

    Daily Oil Rate No Zeros:=FILTER(SourceData[Oil Rate],SourceData[Oil Rate]>0)

    Thanks!

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Filtering out zeros and blanks

    You are looking to use this table in another formula? What is your "wrapping" function for this?
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    07-15-2013
    Location
    Denver,CO
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Filtering out zeros and blanks

    The ultimate goal is to create a rolling 7 day average based on the oil rate column. But I need to filter out the zeros and blanks first and then somehow re-assign the value in days and then spit out the associated rollling 7 day average based on the oil rate

    I was just trying to take it one step at a time.

    Maybe this will help explain it

    This is what is in the table I have

    Days Oil Rate
    0 1.5
    1 3.5
    2 0
    3 6.0
    4 7.1
    5 8.2
    6
    7
    8
    9 4.2
    10 0
    11 2.8
    12 4.8
    13 8.0
    14 7.5
    15 1.9


    I need to Filter Out blanks and Zeros so the days and oil rate columns look like this

    Days Oil Rate
    0 1.5
    1 3.5
    2 6.0
    3 7.1
    4 8.2
    5 4.2
    6 2.8
    7 4.8
    8 8.0
    9 7.5
    10 1.9


    and then calculate the Rolling 7 Day Average as a calculated measure I can use in a pivot table


    Days Oil Rate 7 Day Average
    0 1.5 1.5/1
    1 3.5 (1.5+3.5)/2
    2 6.0 (1.5+3.5+6.0)/3
    3 7.1 (1.5+3.5+6.0+7.1)/4
    4 8.2 (1.5+3.5+6.0+7.1+8.2)/5
    5 4.2 (1.5+3.5+6.0+7.1+8.2+4.2)/6
    6 2.8 (1.5+3.5+6.0+7.1+8.2+4.2+2.8)/7
    7 4.8 (3.5+6.0+7.1+8.2+4.2+2.8+4.8)/7
    8 8.0 (6.0+7.1+8.2+4.2+2.8+4.8+8.0)/7
    9 7.5 (7.1+8.2+4.2+2.8+4.8+8.0+7.5)/7
    10 1.9 (8.2+4.2+2.8+4.8+8.0+7.5+1.9)/7


    Does that make sense?

    Here is the formula I am using that does not take out the zeros and blanks from the calculation or reassign the days values - so I was trying to create a measure that would.

    7 Day Average(Daily Oil Rate):=IF(COUNTROWS(VALUES(SourceData[Days])) = 1, CALCULATE(AVERAGEX(VALUES(SourceData[Days]), SourceData[Sum of Oil Rate]),SourceData[Days] <= VALUES(SourceData[Days]) && SourceData[Days]> VALUES(SourceData[Days]) -7),BLANK())
    Last edited by hbusche; 07-25-2013 at 02:26 PM.

  4. #4
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Filtering out zeros and blanks

    Hmm.. I've used PowerPivot a bit, and that filter function needs to be "wrapped".

    Either way, I think i see what you are wanting and you can do it with a worksheet formula. Look at cell D2 in the attachment. You can add dates and values to columns A and B and the average will adjust.

    {=AVERAGE(INDEX(B:B,(LARGE(ROW(A:A)*(B:B>0),7))):INDEX(B:B,(LARGE(ROW(A:A)*(B:B>0),1))))} -- This is an array formula, you don't type the curly braces, type the rest and press cntrl+shift+enter
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-15-2013
    Location
    Denver,CO
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Filtering out zeros and blanks

    Thank you very much for making a suggestion - I don't know if I am not explaining it right or of it is impossible but I am having some trouble getting this question answered.

    I currently have this working using worksheet formulas. There is a lot more data associated with this and I am trying to make an entire process easier, this is just one small step, so I would like to do it in PowerPivot if it is possible.
    I will try using my current dax function as a wrapper and incorporating the filter function and see if that works. If there are any additional suggestions I will glad take them.

    Thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Help with Vlookup blanks and zeros
    By consulttk in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-27-2012, 10:40 AM
  2. Fill blanks with zeros
    By Snark in forum Excel General
    Replies: 1
    Last Post: 07-15-2008, 04:33 PM
  3. formulas with blanks and zeros
    By rebraku in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 09-18-2007, 06:39 PM
  4. Blanks chart as zeros
    By CLR in forum Excel Charting & Pivots
    Replies: 10
    Last Post: 04-10-2005, 09:06 PM
  5. Ignore blanks or zeros
    By gil0730 in forum Excel General
    Replies: 1
    Last Post: 02-03-2005, 12:12 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1