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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
NewPBIe
Helper II
Helper II

New, active and closed Contracts

Hello everybody. I've got a Date Table (Calender) and a Table with IDs, Start date and End date for some Contracts (Data).

 

I need to answer three different questions pro each Period (fiscal year october - september):

1. how many new contracts  (in this period)

2. how many active contracts (from this and the previus periods)

3. how many closed contracts (in this period)

 

Now 1 and 3 are easy: I connected Calender[Date] with both [Start Date] and [End Date] from Data and selected the correct relastionship between the Tables. 

 

I am stuck with 2, since I can' t ignore the active relationship and every measure keeps counting the new contracts and not the active ones. 

 

Sample Data / Input:

 

IDSTARTEND
A16.10.202030.08.2021
B16.10.202031.01.2021
C21.12.202031.04.2021
D13.01.2021 
E08.03.202130.06.2021
F01.09.202130.09.2021

 

 

Output:

 New ClosedActivewhich IDs should be counted in active
Okt. 20202A;B
Nov. 20002A;B
Dez. 20103A;B;C
Jan. 21114A;B;C;D
Feb. 21003A;C;D
Mrz. 21104A;C;D;E
Apr. 21014A;C;D;E
Mai. 21003A;D;E
Jun. 21013A;D;E
Jul. 21002A;D
Aug. 21012A;D
Sep. 21112D;F

 

What am I doing wrong? Thank you in advance!

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Try

Active contracts =
VAR ReferenceDate =
    MAX ( 'Calendar'[Date] )
VAR Result =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        REMOVEFILTERS ( 'Date' ),
        'Table'[Start date] <= ReferenceDate
            && (
                ISBLANK ( 'Table'[End date] )
                    || 'Table'[End date] > ReferenceDate
            )
    )
RETURN
    Result

View solution in original post

1 REPLY 1
johnt75
Super User
Super User

Try

Active contracts =
VAR ReferenceDate =
    MAX ( 'Calendar'[Date] )
VAR Result =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        REMOVEFILTERS ( 'Date' ),
        'Table'[Start date] <= ReferenceDate
            && (
                ISBLANK ( 'Table'[End date] )
                    || 'Table'[End date] > ReferenceDate
            )
    )
RETURN
    Result

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.