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

Using 2 dates (Start & End) to get one continue colomne date

Hi All,

 

I'm losing my mind trying to resolve this problem if you can help me please :

 

I've got a table getting all my product with a start and end date of the promotion :

Capture.JPG

so, I want to use this table to calculate the number of days which the product was in promotion

 

I have in my mind to build a new table with a unique date from the start to the end date

Capture.JPG

 

any idea how to do this?

 

If you have another idea, I'll be grateful for your help.

 

Regards

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

HI @nkasdali,

 

You can simply use below formula to create expand table with detail date range :

 

Detail Table =
VAR _calendar =
    CALENDAR ( MINX ( 'Product', [Start] ), MAXX ( 'Product', [End] ) )
RETURN
    SELECTCOLUMNS (
        FILTER (
            CROSSJOIN ( 'Product', _calendar ),
            [Date] >= [Start]
                && [Date] <= [End]
        ),
        "Product", [Product],
        "Date", [Date]
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

HI @nkasdali,

 

You can simply use below formula to create expand table with detail date range :

 

Detail Table =
VAR _calendar =
    CALENDAR ( MINX ( 'Product', [Start] ), MAXX ( 'Product', [End] ) )
RETURN
    SELECTCOLUMNS (
        FILTER (
            CROSSJOIN ( 'Product', _calendar ),
            [Date] >= [Start]
                && [Date] <= [End]
        ),
        "Product", [Product],
        "Date", [Date]
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
AlexanderBlair
Advocate I
Advocate I

Hi, 

 

If I understand correctly you want to have the number of days between the start and end date? A method for doing this is using the DATEDIFF function in a Calculated Column. 

 

Number of Days = DATEDIFF(YourTableName[StartDate].[Date],YourTableName[EndDate].[Date],DAY)

Let me know if this works!

 

Cheers

 

Alex

 

Thanks Alexander,
I didn't, but I realized that I can't use my filter date on this case. Exemple : if I select January, I ll have 15 days, February 31 days.

My apologies, I forgot to specify this need.

Regards

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.