Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Only displaying 0 when between other Data

Goodday,   I have a problem and hope you guys can help. I have the following graph, where i replaced blank values with 0: My goal is to make it like this     This Graph Follows a sl...
  • daXtreme's avatar
    4 years ago

    Dates is a dim that stores all dates from the 2000 year.

    Graph Value = 
    var CurrentDate = SELECTEDVALUE( Dates[Date] )
    var MinDateWithNonZeroData =
        CALCULATE(
            MINX(
                FILTER(
                    Graph,
                    Graph[Value] > 0
                ),
                Graph[Date]
            ),
            ALLSELECTED( Dates )
        )
    var MaxDateWithNonZeroData =
        CALCULATE(
            MAXX(
                FILTER(
                    Graph,
                    Graph[Value] > 0
                ),
                Graph[Date]
            ),
            ALLSELECTED( Dates )
        )
    var GraphValue = 
        if( MinDateWithNonZeroData <= CurrentDate 
                && CurrentDate <= MaxDateWithNonZeroData
                && not ISBLANK( MinDateWithNonZeroData ),
            CALCULATE(
                SUM( Graph[Value] ) + 0,
                TREATAS(
                    { CurrentDate },
                    Graph[Date]
                )
            )
        )
    return
        GraphValue