on 08-10-2016 1:44 PM
Hello,
I've been looking around trying to find an explanation on how to do this, but I'm struggling to find anything of use.
I need to make a Custom Calculation to filter out any data older than 3 months. Basically, I just want my visualization to show data from the past 3 months from the current date. It needs to update when looking at the file to always only show the last 3 months of data (which is why I can't just use a filter).
Could anyone give me some insight on how this works?
Thanks,
Alec
What I've done in the past is create a custom dimension. The basic formula looks something like this:
if (date today - date of the record) >= target number of timeperiods then 0 else 1
then filter for only the 1's (or 0's depending on what you need).
This will basically set a flag that allows for filtering. Because you're using calculating relative to today (use the today function, not a date literal), the viz will dynamically update to only show the relevant months.
You may also need to do a ton of data manipulations, depending on your source, to get from a text date to an actual date field that allows for calculations.
FYI - in using Lumira, you will end up setting a TON of flags. It's the easiest way to do some forms of conditional logic.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jay,
Thanks for the advice! I think I'm on the right track, but I'm struggling to finalize this. I'm trying to use the 'DateDiffInMonths' function, but I'm not sure what values to put in the function. I tried using 'Month(CurrentDate())' and 'Month({Date})', but those return an integer rather than a date value.
Also, I'm not really sure what to put after the conditions. Right now I have >= 3 (to signify 3 months), but obviously that's just not going to work.
Here's what I have right now:
I think I'm on the right track with this here:
if DateDiffInMonths(Month(CurrentDate()),AddMonthToDate(CurrentDate(), -3)) >= 3 then 0 else 1
If my understanding is correct, the DateDiffInMonths function should calculate the difference between today's date and today's date minus 3 months. I'm still not quite sure what to put after the >= though.
Here is an example formula from one of my Lumira vizes:
if CurrentDate() > AddMonthToDate({DATA_MONTH}, 4) then "Show" else "Hide"
As for your formula, I believe what you want is:
If DateDiffInMonths({Date}, CurrentDate()) >= 3 then 0 else 1
You are trying to insert a month value from your date fields into the DateDiffInMonths formula but that is an unnecessary step. The formula will take care of that for you.
Welcome to the fun world of Lumira de-bugging!
Are you sure that the {Date Issue Submitted KEY} is a date field? Especially if your datasource is BW, what looks like a date is oftentimes not a date at all, even if it's a key field. For example, I know in our instance of BW, many date fields, even the keys, are actually year/month pairs (like 201601 for example). That's the only thing I can think of that may be screwing up your formula. Lumira is expecting an actual date value in there. (That's one reason why I mentioned above that I go through contortions to get to a true date field in many of my Lumira vizes).
Debugging in any software always turns into such an adventure, haha.
It looks like Lumira realizes that this field is a date, because it puts a little calendar symbol next to it. It does however also have a little question mark:
That field is in a format that looks like this: 7/24/2016
I've also tried making a date/time hierarchy out of that field, but I get the same error when trying to use that in the formula.
Edit: Just to confirm, I am in fact taking this data straight from the BW.
Hi Alec,
don't know what you are trying to do exactly. To get the date 3 month ago you can use:
AddMonthToDate(CurrentDate(), - 3)
Don't know if this helps....
Andreas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What is your data source? If your data source is a BEx query, it is best/easier to do back in the BEx query
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is a BEx query, but it does not have any parameters for the date. I can only bring in the Date field which I've converted into a Lumira Date Dimension. It's theoretically possible for me to request changes to the BEx query, but it would take weeks to go through the approval process and I need to have this done in a couple days, preferably today.
Alec:
I recommend looking at document SAP Lumira Calculation Best Practices | SCN - there are some good tips on date calculations that may help you.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.