cancel
Showing results 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.

Frequent Visitor

## DAX count of weeks between dates based on Dimension

Hi ,

I'm a DAx beginner ,have been struggling to get these 2 calculated measure.

1)for Desired Result1:

Display count the number of weeks between the order date and delivery date for each item,at each date

Ex;

item AB was ordered on 4-April-16 and Delivery date id on 18-Apr-16.

item BC was ordered on 4-April-16 and Delivery date id on 25-Apr-16.

item BC was ordered again on  4-April-16 and Delivery date id on 27-Jun-16.

1)for Desired Result2:

Count the total number of weeks between the order date and delivery date of each item.

3 REPLIES 3
Community Support

Hi @DAXbgnr,

As BhaveshPatel's point of view, I'd like to suggest you creata a table which contain the calculate data. (Order ID, Item Name, Start Date, End date)

Then add a relationship between these tables and use the DATEDIFF and RELATED function to calculate with these date range.

Sample formula:

Result1=  DateDiff(Table[Month,Day,Year],Related(OrderTable[EndDate]),Week)

Result2=  DateDiff(Related(OrderTable[StartDate]),Related(OrderTable[EndDate]),Week)

Regards,

Xiaoxin Sheng

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

I think there is a fundamental flaw in the design of your table.

You need Order Date as well as Delivery Date columns to distinguish between two different dates. Putting it in the same column can complicate your DAX Calculation as well as your data model.

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Frequent Visitor

Thank you ,Xiaoxin and Bhavesh.

I'll try that.

Announcements

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

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors