Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
I would like to understand how to count the number of active "contracts" whose information is based on maturity data and look at the 12-month average. Print for you to check, please help.
Solved! Go to Solution.
if you have a Contract table and Calendar table then you count number of Active contracts you can use something like this
Count of Active Contracts = countrows(calculatetable(all(Contract), Contract(StartDate)<SelectedValue(Calendar[date]) && Contract[MaturityDate}>SelectedValue(Calendar[date]))
Hi, @Anonymous
Based on your description, I assume that you want to count number of active contracts whose start date is earlier than the selected date and the end date is later than the selected date. And then you can average based on these corresponding contracts. I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
Calendar(a calculated table):
Calendar = CALENDARAUTO()
There is no relationship between two tables. You may create two measures as below.
Count =
var tab =
ADDCOLUMNS(
'Table',
"flag",
IF(
ISFILTERED('Calendar'[Date]),
IF(
HASONEVALUE('Calendar'[Date]),
IF(
[Start Date]<=SELECTEDVALUE('Calendar'[Date])&&
SELECTEDVALUE('Calendar'[Date])<=[End Date],
1,0
),
1
),
1
)
)
return
COUNTROWS(
FILTER(
tab,
[flag]=1
)
)
Avg =
var tab =
ADDCOLUMNS(
'Table',
"flag",
IF(
ISFILTERED('Calendar'[Date]),
IF(
HASONEVALUE('Calendar'[Date]),
IF(
[Start Date]<=SELECTEDVALUE('Calendar'[Date])&&
SELECTEDVALUE('Calendar'[Date])<=[End Date],
1,0
),
1
),
1
)
)
return
AVERAGEX(
FILTER(
tab,
[flag]=1
),
[Value]
)
Finally you need to use the 'Date' column from 'Calendar' table to filter the result.
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
It would be that example. I need to know per day / month, the contracts that are active based on their expiration date. My base has a contract since 2015, so I wanted to make an average of the last 12 months from the date shown on the chart or table.
@Anonymous ,The information you have provided is not making the problem clear to me. Can you please explain with an example.
But in case a contract done last 1 month is active, you can try, Join the contract date with
Active = CALCULATE(count(Table[contractid]),filter(date,date[date] <=maxx(date,date[date])))
Active = CALCULATE(count(Table[contractid]),filter(date,date[date] <=max(Sales[contractOn])))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184
Appreciate your Kudos.
Appreciate your Kudos.
Friend,
It would be that example.
I need to know per day / month, the contracts that are active based on their expiration date.
My base has a contract since 2015, so I wanted to make an average of the last 12 months from the date shown on the chart or table.
if you have a Contract table and Calendar table then you count number of Active contracts you can use something like this
Count of Active Contracts = countrows(calculatetable(all(Contract), Contract(StartDate)<SelectedValue(Calendar[date]) && Contract[MaturityDate}>SelectedValue(Calendar[date]))
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
64 |
User | Count |
---|---|
135 | |
120 | |
101 | |
71 | |
61 |