Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
CastroRibeiro
Helper I
Helper I

A column that contains dates in 5-day periods

How to make a column that shows dates in a range of 5 days?
Every 5 days a period would be counted
Example: from 01/01/2022 - 05/01/2022 = Frist period

 from 05/01/2022 - 10/01/2022 = Second period

etc...

 

I already have a calendar table with date and day columns, how to get this date and make a column with periods of 5 days?

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @CastroRibeiro 

 

You can use these DAX expressions to add Period Columns, Sample file attached for your reference:

Period all date = 
VAR _Min_Date =
    CALCULATE ( MIN ( 'Table'[Date] ), ALL ( 'Table' ) ) - 1
VAR _Date = 'Table'[Date]
VAR _Day_Between =
    DATEDIFF ( _Min_Date, _Date, DAY )
VAR _Period_Number =
    ROUNDUP ( _Day_Between / 5, 0 )
RETURN
    "Period " & _Period_Number
Period By Month = 
VAR _Min_Date =
    CALCULATE (
        MIN ( 'Table'[Date] ),
        ALLEXCEPT ( 'Table', 'Table'[Date].[Month] )
    ) - 1
VAR _Date = 'Table'[Date]
VAR _Day_Between =
    DATEDIFF ( _Min_Date, _Date, DAY )
VAR _Period_Number =
    ROUNDUP ( _Day_Between / 5, 0 )
RETURN
    "Period " & _Period_Number

Output:

VahidDM_0-1654299103643.png

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

FIFA World Cup - Medal Records 

 

 





View solution in original post

1 REPLY 1
VahidDM
Super User
Super User

Hi @CastroRibeiro 

 

You can use these DAX expressions to add Period Columns, Sample file attached for your reference:

Period all date = 
VAR _Min_Date =
    CALCULATE ( MIN ( 'Table'[Date] ), ALL ( 'Table' ) ) - 1
VAR _Date = 'Table'[Date]
VAR _Day_Between =
    DATEDIFF ( _Min_Date, _Date, DAY )
VAR _Period_Number =
    ROUNDUP ( _Day_Between / 5, 0 )
RETURN
    "Period " & _Period_Number
Period By Month = 
VAR _Min_Date =
    CALCULATE (
        MIN ( 'Table'[Date] ),
        ALLEXCEPT ( 'Table', 'Table'[Date].[Month] )
    ) - 1
VAR _Date = 'Table'[Date]
VAR _Day_Between =
    DATEDIFF ( _Min_Date, _Date, DAY )
VAR _Period_Number =
    ROUNDUP ( _Day_Between / 5, 0 )
RETURN
    "Period " & _Period_Number

Output:

VahidDM_0-1654299103643.png

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

FIFA World Cup - Medal Records 

 

 





Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.