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

Create a calculated column for a specifik date range

Hi,

I need help with creating a calculated column in my date table, "Date_tabel". I would like to have 1 if it is between last 25:th and the 25:th before that otherwise 0. 

For example:
1. Today (the 14:th of march) I would like to have the dates between 25:th of january and 25:th of february marked up. 
2. The 26:th of march I would like to have the dates between 25:th of february and the 25:th of march marked up

 

Thnak you!

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

Hi @Regnbagar1 ,

Please refer to my pbix file to see if it helps you. 

Create a column.

Column =
VAR _previous1 =
    DATE ( YEAR ( EDATE ( TODAY (), -1 ) ), MONTH ( EDATE ( TODAY (), -1 ) ), 25 )
VAR _previous2 =
    DATE ( YEAR ( EDATE ( TODAY (), -2 ) ), MONTH ( EDATE ( TODAY (), -2 ) ), 25 )
RETURN
    IF (
        'Table'[date] > _previous2
            && 'Table'[date] <= _previous1,
        1,
        IF ( TODAY () >= _previous1, 0, BLANK () )
    )

11.PNG

If I have misunderstood your meaning, please provide your desired output and your pbix without privacy information.

 

Best Regards

Community Support Team _ Polly

 

 

View solution in original post

6 REPLIES 6
v-rongtiep-msft
Community Support
Community Support

Hi @Regnbagar1 ,

Please refer to my pbix file to see if it helps you. 

Create a column.

Column =
VAR _previous1 =
    DATE ( YEAR ( EDATE ( TODAY (), -1 ) ), MONTH ( EDATE ( TODAY (), -1 ) ), 25 )
VAR _previous2 =
    DATE ( YEAR ( EDATE ( TODAY (), -2 ) ), MONTH ( EDATE ( TODAY (), -2 ) ), 25 )
RETURN
    IF (
        'Table'[date] > _previous2
            && 'Table'[date] <= _previous1,
        1,
        IF ( TODAY () >= _previous1, 0, BLANK () )
    )

11.PNG

If I have misunderstood your meaning, please provide your desired output and your pbix without privacy information.

 

Best Regards

Community Support Team _ Polly

 

 

Thank you so much for the help!

Regnbagar1
Helper I
Helper I

Hi,

 

Thank for the feedback. In my date table (see picture) I want to create a calculated dynamic table called "date range". The dates that are between the 25:th and 25:th the month before should have a 1 in "date range" column. In the example below the dates between 25:th of january and 25:th of february shoud have 1 in "date range" column and the rest of the dates 0 in "date range" column. 

Skärmavbild 2022-03-14 kl. 11.45.03.pngKind Regards

@Regnbagar1 , try a new column like

if([Date] <= Today() ,if(Day([Date])<=25, datediff(eomonth([Date],-2) +26 ,datediff(eomonth([Date],-1) +26) ,today(),month), blank())

Thank you so much. When I try the function I get the error message "Too few arguments were passed to the DATEDIFF function. The minimum argument count for the function is 3." 

 

Do you know how I can handle that in the best way?

amitchandak
Super User
Super User

@Regnbagar1 ,The information you have provided is not making the problem clear to me. Can you please explain with an example.
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Appreciate your Kudos.



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.