Forum Discussion

subho220's avatar
subho220
Helper I
5 years ago
Solved

Incremental dateI

Hello Community,   I have a date column(Lab Date) and I want to show Count of samples by 10 day increment  which will look like this -> How can I achieve that? Please help
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi subho220 ,

    According to my understand, you want to set a segment for Date and then use it as X-axis in chart,right?

    You could use the following formula to create a column not a measure.

    Type =
    VAR _max =
        CALCULATE ( MAX ( 'Table'[Date] ), ALL ( 'Table'[Date] ) )
    VAR _diff =
        DATEDIFF ( _max, MAX ( 'Table'[Date] ), DAY )
    RETURN
        IF (
            _diff <= 10,
            "<10 days",
            IF (
                _diff > 10
                    && _diff <= 20,
                "11-20 days",
                IF (
                    _diff > 20
                        && _diff <= 30,
                    "21-30 days",
                    IF (
                        _diff > 30
                            && _diff <= 40,
                        "31-40 days",
                        IF ( _diff > 40 && _diff <= 50, "41-50 days", IF ( _diff > 50, ">50 days" ) )
                    )
                )
            )
        )

    My visualization looks like this:

    Here is the pbix file.

     

    Did I answer your question ? Please mark my reply as solution. Thank you very much.
    If not, please upload some insensitive data samples and expected output.

     

    Best Regards,
    Eyelyn Qin