Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a statement that i can never get to work with a date field. It is below:
Count({$<[BusinessDate]= {'$(=If(GetSelectedCount([BusinessDate]) < 1, Max([BusinessDate]), [BusinessDate]))'}>} MemberNbr)
I am trying to get a count of MemberNbrs for the month and set the max BusinessDate as the default if there are no selections made. If i make a selection then i get the results i would expect. If i select the max date on a chart then i get the count i want, but if there is no selection then my KPI shows 0.
It works fine if the BusinessDate is a text field. However when the BusinessDate is a date field then the KPI returns 0. Any ideas what i am doing wrong?
Try this script:
Table:
LOAD
MembershipMonthlySKey,
Date(MonthStart(Date#(MonthID, 'YYYYMM')), 'YYYYMM') as MonthID,
Date(BusinessDate) as BusinessDate
FROM [lib://Lib/TestData.xlsx]
(ooxml, embedded labels, table is Sheet1);
and these two expressions should work for you
Count({$<[MonthID]= {"$(=Date(Max([MonthID]), 'YYYYMM'))"}>} MonthID)
Count({$<BusinessDate= {"$(=Date(Max(BusinessDate)))"}>} MonthID)
Have you tried this:
Count({$<[BusinessDate]= {"$(=Max([BusinessDate]))"}>} MemberNbr)
or this
Count({$<[BusinessDate]= {"$(=Date(Max([BusinessDate]), 'DateFieldFormatHere'))"}>} MemberNbr)
so what i am really trying to do is get the previous months count, I tired
Count({$<[BusinessDate]= {"$(=addmonths(Max([BusinessDate])),-1)"}>} MemberNbr)
May be something like this:
Count({$<[BusinessDate]= {"$(=AddMonths(Max([BusinessDate])),-1))"}>} MemberNbr)
or
Count({$<[BusinessDate]= {"$(=Date(AddMonths(Max([BusinessDate])),-1), 'DateFieldFormatHere'))"}>} MemberNbr)
Thanks for the response but neither of those are working either, i still cant figure out why.
For example this code works just fine:
Count({$<[MonthID]= {$(=If(GetSelectedCount([MonthID]) = 0, max([MonthID]), [MonthID]))}>} MemberNbr)
MonthID is a character field that says '201601' as an example. This works.
But when i use the same code as and the field is a date then it doesnt work:
Count({$<[MDate]= {$(=If(GetSelectedCount([MDate]) = 0, max([MDate]), [MDate]))}>} MemberNbr)
where Mdate is a date field.
What is your MDate format? DD/MM/YYYY or MM/DD/YYYY or something else?
Mdate is YYYY-MM-DD
Have you already tried this?
Count({$<[MDate]= {$(=Date(Max([MDate]), 'YYYY-MM-DD'))}>} MemberNbr)
This should be a helpful link to read Dates in Set Analysis
If for some reason this doesn't work, then the next thing you need to check is that if MDate is a dual field with numeric value or not. For that you can see these blogs
I tried the one above with no luck, thanks again, i will check out these articles and post the result if i can figure it out.