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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Fabcon_Europe_Social_Bogo

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.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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