The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi,
I am looking to calculate and visualise number of active contracts on continious time x axis. Looking at the chart I should be able to identify min and max number of active contracts at any day.
Active from | Active to | Contract |
10/01/2023 | 20/01/2023 | A |
12/01/2023 | 23/03/2023 | B |
20/01/2023 | 31/01/2023 | C |
23/01/2023 | 05/04/2023 | D |
24/01/2023 | 08/02/2023 | E |
06/02/2023 | 24/03/2023 | F |
08/02/2023 | 23/02/2023 | G |
Would anyone be able to help or direct me where to start?
Solved! Go to Solution.
You can use
Active contracts =
VAR MaxDate =
MAX ( 'Date'[Date] )
VAR Result =
CALCULATE (
COUNTROWS ( 'Table' ),
'Table'[Active from] <= MaxDate
&& 'Table'[Active to] >= MaxDate
)
RETURN
Result
Make sure that there are no active relationships between your date table and fact table, or if there are you will need to add REMOVEFILTERS('Date') into the CALCULATE
I nneeded to create calendar column first.
Formula worked without MAX before ('Date'[Date]
You can use
Active contracts =
VAR MaxDate =
MAX ( 'Date'[Date] )
VAR Result =
CALCULATE (
COUNTROWS ( 'Table' ),
'Table'[Active from] <= MaxDate
&& 'Table'[Active to] >= MaxDate
)
RETURN
Result
Make sure that there are no active relationships between your date table and fact table, or if there are you will need to add REMOVEFILTERS('Date') into the CALCULATE
User | Count |
---|---|
25 | |
10 | |
8 | |
6 | |
5 |
User | Count |
---|---|
31 | |
10 | |
10 | |
10 | |
9 |