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
subho220
Helper I
Helper I

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 ->

subho220_0-1603988943772.png

How can I achieve that? Please help

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

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:
11.2.8.1.PNG

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

View solution in original post

3 REPLIES 3
v-eqin-msft
Community Support
Community Support

Hi @subho220 ,

 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.

 

Best Regards,
Eyelyn Qin

v-eqin-msft
Community Support
Community Support

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:
11.2.8.1.PNG

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

amitchandak
Super User
Super User

@subho220 , Create a new column like

new column =
var _diff = datediff([Lab Date], today(),day)
return
switch(true(),
_diff<10 , " Less than 10 days",
_diff<20 , " 11 to 20 Days ",
//add other
)

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.