Forum Discussion
Logical Count Function.
See Below: All of my tables are Related Direct Queires from SQL. I am wanting to track how many loans are in the application process.
To do so, I am using dates. So in my main database, I am wanting to know how many loans that have an application date, but do not have an assigned date.
My count =
- speedramps6 years agoSuper User
Hi again TSP
Please provide screen prints of the tables and columns next time.
You knew what you meant, but it was not 100% clear to me from your text.
I have added comments to this measure so hopefully you can fathom the solution now, but ask for more help if needed
My count =
-- get a list of all loans with blank assignments on TableA
VAR AssignmentsBlank =
CALCULATETABLE(VALUES(TableA[LoanID]),
FILTER(ALL(TableA),
TableA[AssignedDate] = BLANK() ))-- get a list of all loans with application dates on TableB
VAR ApplicationsNotBlank =
CALCULATETABLE(VALUES(TableB[LoanID]),
FILTER(ALL(TableB),
TableB[ApplicationDate] <> BLANK() ))-- get a list of all loans on both lists
VAT Onboth = INTESECT( ApplicationsNotBlank, AssignmentsBlank)RETURN
-- counts loans on both
COUNTROWS(Onboth) - speedramps6 years agoSuper User
Sorry about the typo. Yes of course INTESECT should be INTERSECT.
I have created this example you. So you can look at the data, relationships and data measure
Download this exampleThis counts the number of loans that have blank TableA[AssignedDate] and not blank TableB[ApplicationDate].
Note only loans 2, 4 and 7 fullfill this condition. So My count = 3.
My counts =
-- get a list of all loans with blank assignments on TableAVAR AssignmentsBlank =CALCULATETABLE(VALUES(TableA[LoanID]),FILTER(ALL(TableA),TableA[AssignedDate] = BLANK() ))-- get a list of all loans with application dates on TableBVAR ApplicationsNotBlank =CALCULATETABLE(VALUES(TableB[LoanID]),FILTER(ALL(TableB),TableB[ApplicationDate] <> BLANK() ))-- get a list of all loans on both listsVAR Onboth = INTERSECT(ApplicationsNotBlank, AssignmentsBlank)RETURN-- counts loans on bothCOUNTROWS(Onboth) - Anonymous6 years agoNot applicable
This works almost exactly how I need it to, but I think I need to specify that the loan "has" to have an application date. Would I include that filter in the 2nd VAR?
Thank you for your help,
- speedramps6 years agoSuper User
Hi again TPN
Thank you for your kudos, I enjoyed helping you during lockdown
Sorry, I just assumed all the applications would have an application date.
You can change the 2nd var using CALCULATETABLE with FILTER to just get a list of applications with an application date, like this ...
My count =
VAR AssignedLoans =
CALCULATETABLE(VALUES(LoanTable[LoanID]),
FILTER(ALL(LoanTable),
LoanTable[AssignedDate] <> BLANK() ))VAR Applications =
CALCULATETABLE(VALUES(ApplicationsTable[LoanID]),
FILTER(ALL(ApplicationsTable),
ApplicationsTable[AppliedDate] <> BLANK() ))RETURN
COUNTROWS(
EXCEPT( Applications, AssignedLoans)
) - Anonymous6 years agoNot applicable
See below: The original formula worked closely, but I had to add a filter to the graph to get it to work.
Now this is what I have, and the tables and counters are not populating.
To reiderate: When Assigned Date IS Blank, then count loans that have an application date.
- Anonymous6 years agoNot applicable
"-- get a list of all loans on both lists
VAT Onboth = INTESECT( ApplicationsNotBlank, AssignmentsBlank)"Just to make sure this is "VAR" on both and "INTERSECT"
I have done exactly that, the table actually loads with column names, but no data.
Thank you,
- Anonymous6 years agoNot applicable
I accept that this would probably work in most scenarios. However, I think there may be some limitations regarding our SQL queries.
I can do the first part by itself and it will create a table, I can also do the same with the 2nd table.
When I do both and try to intersect, nothing populates.