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
rolf1994
Helper II
Helper II

Calculate number of units between multiple dates

Hi,

 

I have the following table. For every month there is one line that contains the amount of Units for the period (month). Type = 'Service':

 

Start dateEnd dateUnitsType
1-jan31-jan32Service
29-jan31-jan-1Adjustment
1-feb28-feb31Service
1-mrt31-mrt31Service

 

When there is an adjustment during the month a new line gets created with the change in quantity. i.e. on the 29th of january the quantity is decreased by 1. Type = 'Adjustment'

 

I want to create an area chart that shows me 32 units from the 1st of january untill the 28th of januari and 31 units from the 29th of january. Something like this:

 

DateUnits
1-jan32
2-jan32
3-jan32
32
29-jan31
30-jan31
31-jan31
1-feb31

 

 

Would that be possible?

1 ACCEPTED SOLUTION
v-jiascu-msft
Employee
Employee

Hi @rolf1994,

 

Please check out the demo in the attachment. 

1. Create a date table if you don't have one.

2. Establish a relationship.

3. Create a measure.

Measure =
CALCULATE (
    SUM ( Table1[Units] ),
    FILTER (
        ALL ( 'Table1' ),
        MIN ( 'Calendar'[Date] ) >= 'Table1'[Start date]
            && MIN ( 'Calendar'[Date] ) <= 'Table1'[End date]
    )
)

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-jiascu-msft
Employee
Employee

Hi @rolf1994,

 

Please check out the demo in the attachment. 

1. Create a date table if you don't have one.

2. Establish a relationship.

3. Create a measure.

Measure =
CALCULATE (
    SUM ( Table1[Units] ),
    FILTER (
        ALL ( 'Table1' ),
        MIN ( 'Calendar'[Date] ) >= 'Table1'[Start date]
            && MIN ( 'Calendar'[Date] ) <= 'Table1'[End date]
    )
)

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.