QlikSense Expression Displaying only Previous Month's Values - qlikview

I have started working with QS recently and I have a problem with defining an expression which will allow me to display previous month's data.
I have tried creating previous month variable:
vPreviousMonth = MonthName(Addmonths(Max([Calendar Termination Month]),-1))
however this did not work - retrieves value 0. Then I tried below:
If(MonthStart([Calendar Termination Month])=MonthStart(Today()),-1,0) as PreviousMonth which doesn't work either - retrieves current month's values, used in below expression:
sum({<PreviousMonth={"-1"}>} [Terminated]).
Lastly, I tried
sum({$<[Calendar Termination Month]={"$(=[Calendar Termination Month](AddMonths(Max(Date),-1),'YYYY-MM'))"}>}[Terminated])
which, surprise!, retrieved 0 value as well.
Is there any way I can somehow make this work?

Try this
sum({$<[Calendar Termination Month]={"$(=month(AddMonths([Termination Date],-1))))"}>}[Terminated])

Related

How do I write a query using the VersionOne API to return all the hours (actuals) recorded under an Epic?

I need to write a query using the VerisonOne API to return all the time (effort) recorded against tasks under a specific Epic. My goal is to have the query be a one line statement I can enter into the address bar of my browser.
I've tried the following using the rest-1.v1 query:
http://<>/VersionOne/rest-1.v1/Data/Epic?sel=Epic.ID.Number,SubsAndDown:PrimaryWorkitem[AssetState=%27Closed%27].Actuals.Value.#Sum&where=Epic.ID.Number=%27E-06593%27
http://<>/VersionOne/rest-1.v1/Data/Story?sel=Story.ID.Number,Story.Name,SuperAndUp.Number,SuperAndUp.Actuals.#Sum&where=Story.SuperAndUp.ID.Number=%27E-06593%27
Below is the output from the first query above. (similar results from the second query)
Assets total="1" pageSize="2147483647" pageStart="0"
Asset href="/VersionOne/rest-1.v1/Data/Epic/1481442" id="Epic:1481442"
Attribute name="SubsAndDown:PrimaryWorkitem[AssetState='Closed'].Actuals.Value.#Sum"/
/Asset
/Assets
Actual results were no hours returned. I expected to have ~4,320 hours returned (the total under the Epic E-06593) after the ...#Sum"/
On your first query
http://<>/VersionOne/rest-1.v1/Data/Epic?sel=Epic.ID.Number,SubsAndDown:PrimaryWorkitem[AssetState=%27Closed%27].Actuals.Value.#Sum&where=Epic.ID.Number=%27E-06593%27,
If you change to AssetState!=Closed then you will get results. Beware there could be another AssetState that might mess with your total hours.
You might want filter down to AssetState= "64" or "Active".
See here for https://community.versionone.com/VersionOne_Connect/Developer_Library/Getting_Started/Platform_Concepts/Asset_State

QlikView set analysis with date: nothing result

I have a problem with a set analysis in QlikView with the date.
I have created a table that contains the sales order.
One field contains the dates of requesting products.
Now if I use a set analysis to filter the data, I receive 0.
The code used that is not working is below.
If I use a set analysis with one date (see below) I receive the orders that have that date in Ord.Original.Req.Date.
Any suggestion?
code not working:
sum({$< Ord.Campain={$(=(max(Ord.Campain)-1))},
Ord.Original.Req.Date = {"$(='<=' & Date(monthend($(vMaxDateAP)), 'DD/MM/YYYY')"}>}
Ord.T.Amm)
code working but with one date:
sum({$<[Ord.Original.Req.Date] ={'31/01/2018'}>}Ord.T.Amm)
try this
sum({$< Ord.Campain={"$(=max(Ord.Campain)-1)"}, Ord.Original.Req.Date = {"<=$(=Date(monthend($(vMaxDateAP)), 'DD/MM/YYYY'))"}>}Ord.T.Amm)

Scribe Jobs: how to get the current date and compare it?

Honesty I'm very new in terms of Scribe Jobs, but I have been trying to develop a Job that get the current date and compare it against one field from the source (CRM input Date).
This is the code in the formula editor of the Pre-Operation Step Control:
IF(S146 =TODAY( ), GOTOSTEP ( ),FAILROW( ))
I'm trying to allow the migration only for records inserted today, the rest will just generate error.
Can somebody help me?
Try this:
if( DATEDIFF ("d", GETCURRENTUTCTIME, S146) < 1 )
Here's a great place to look for more information:
http://help.scribesoft.com/scribeonline/en/sol/formulas/datefunctions.htm

Is it possible to add multiple SetExpressions within an IF statement?

I am having troubles trying to make a graph work. I am not entirely sure if this is possible, thus me asking here. I have below graph, which has the expression:
=Count{<Year='2014','2015','2016'},Month='Jan','Feb','Mrt','Apr','Mei','Jun','Jul','Aug','Sep','Okt','Nov','Dec'}>}DISTINCT sicknumber)
So it doesnt change with whatever selection has been made in the filters. it always shows 2014, 2015, 2016
I want to be able to make the graph non static based on the filter that is given. If I select year 2015 I want to show the previous year and the year after. so when selecting 2013 I want to see 2012, 2013 and 2014. I have made the following expression:
=
if(Jaar = '2016',(Count({<Jaar={'2015','2016'},Maand={'Jan','Feb','Mrt','Apr','Mei','Jun','Jul','Aug','Sep','Okt','Nov','Dec'}>}DISTINCT Ziekte_Volgnummer)),
if(Jaar = '2015',(Count({<Jaar={'2014','2015','2016'},Maand={'Jan','Feb','Mrt','Apr','Mei','Jun','Jul','Aug','Sep','Okt','Nov','Dec'}>}DISTINCT Ziekte_Volgnummer)),
if(Jaar = '2014',(Count({<Jaar={'2013','2014','2015'},Maand={'Jan','Feb','Mrt','Apr','Mei','Jun','Jul','Aug','Sep','Okt','Nov','Dec'}>}DISTINCT Ziekte_Volgnummer)),
if(Jaar = '2013',(Count({<Jaar={'2012','2013','2014'},Maand={'Jan','Feb','Mrt','Apr','Mei','Jun','Jul','Aug','Sep','Okt','Nov','Dec'}>}DISTINCT Ziekte_Volgnummer)),
if(Jaar = '2012',(Count({<Jaar={'2011','2012','2013'},Maand={'Jan','Feb','Mrt','Apr','Mei','Jun','Jul','Aug','Sep','Okt','Nov','Dec'}>}DISTINCT Ziekte_Volgnummer)))))))
it seems however that it ignores the set expression and just show the year given in the filter. How would I go around this.
When using the same statement to just calculate to total unique values in a text object, it does seem to be able to calculate the correct value there.
how would I go around this, of is it even possible?
thanks in advance
=Count({<Jaar={$(=Max(Jaar) - 1), $(=Max(Jaar)), $(=Max(Jaar) + 1)}, Maand>} DISTINCT Ziekte_Volgnummer)
Seems to be the right answer.

Time.now.beginning_of_year does not start at the beginning of the year

Trying to get records that were created this year, I stumbled upon this great question. The second answer says you get all records from a model that were created today by saying:
Model.where("created_at >= ?", Time.now.beginning_of_day)
So, naturally, I tried the same thing with Time.now.beginning_of_year, and it works just fine.
However, what struck me as interesting is that the outputted query (I tried it in the console) is
SELECT COUNT(*) FROM `invoices` WHERE (created_at >= '2012-12-31 23:00:00')
I wasn't aware that 2013 already began at 2012-12-31 23:00:00? How's that?
If you haven't set it yet, you should set your timezone in the config/application.rb file. Look for the line that begins with config.time_zone. (If you aren't sure what value to give, you can run rake time:zones:all to get a list of all available timezones.)
Once you've set your timezone, you should use Time.zone.now, as opposed to Time.now. This will properly "scope" your times to your timezone.
Check the API for more details on TimeWithZone.