Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Dax start at first non blank value

Hi,   My data runs from the years 1960 to 2070 with many 0 values at either side but also some 0 values through the "middle" portion of my data. If I sum the values with a measure and put them in a...
  • AlB's avatar
    7 years ago

    Hi Anonymous 

    You could check whether the cumulative sum so far is zero, and in that case return blank. Something like 

    Measure = 
    IF ( [CumulativeSum] <> 0, [YourMeasure] )

    Please mark the question solved when done and consider giving kudos if posts are helpful.

    Cheers  Datanaut

  • v-frfei-msft's avatar
    7 years ago

    Hi Anonymous,

     

    One sample for your reference, please check the following steps as below.

    1. Insert an index column in power query.

     

    2. To create two calcualted columns.

    Countrows = CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[value]=0 && 'Table'[year]<=EARLIER('Table'[year])))
    Tags = 
    VAR ind = 'Table'[Index] + 1
    VAR ca =
        CALCULATE (
            MAX ( 'Table'[Countrows] ),
            FILTER ( 'Table', 'Table'[Index] = ind )
        )
    var indmin = CALCULATE(MIN('Table'[Index]),FILTER('Table','Table'[value]<>0))-1
    RETURN
        IF ( 'Table'[value] = 0 && 'Table'[Countrows] <> ca || 'Table'[Index]=indmin, "ignore", "count" )
    

    3. Then we can get the excepted reulst by filtering the Tags column.

    For more details, please check the pbix as attached.