Why am I getting an additional riser/bar in my chart in crystal reports - crystal-reports

So I have a chart that looks like this:
Here is what I have in the chart expert:
And here is the code for #ZZ_TAT_Name - A:
if {IB_MESSAGES.MSG_ID} = next({IB_MESSAGES.MSG_ID}) and {IB_MESSAGES.MSG_ID} = previous({IB_MESSAGES.MSG_ID}) then "na" else
IF {#Final Turnaround Minutes} > 0 and {#Final Turnaround Minutes} < 15 THEN "UNDER 15"
ELSE IF {#Final Turnaround Minutes} >= 15 and {#Final Turnaround Minutes} < 30 THEN "BETWEEN 15 & 30"
ELSE IF {#Final Turnaround Minutes} >= 30 and {#Final Turnaround Minutes} < 60 THEN "BETWEEN 30 & 60"
ELSE if {#Final Turnaround Minutes} > 60 then "OVER 60"
//else "*Total Messages"
I am wanting to get rid of the riser that shows 11. That riser is the total DistinctCount of IB_MESSAGES.MSG_ID. How would I be able to remove this? Why is this even showing up?

From what you've mentioned below, it seems 11 out of 22 records appear to fall into none of the if-else categories, leading to the unlabeled blue column. The easiest way to proceed is to intervene before the chart is rendered and reduce the incoming data to only values that belong in the other columns:
There's a few ways to handle this, but I would recommend adding an intermediary Formula that returns the exact same records, except any record that doesn't meet the if/else standards will be replaced with null. Something like:
IF (
{IB_MESSAGES.MSG_ID} = next({IB_MESSAGES.MSG_ID})
AND
{IB_MESSAGES.MSG_ID} = previous({IB_MESSAGES.MSG_ID})
)
OR (
{#Final Turnaround Minutes} > 0
AND
{#Final Turnaround Minutes} > 60
)
THEN
//repeat the original value here
ELSE
null
Done correctly, the intermediary formula will return 11 records and 11 nulls when evaluated in the Details section of the report. From here, you can change your chart to read the formula and it should evaluate only 11 non-null values.

Related

Keeping orders from closing if conditions are met & multiple orders

First time coding - trying to set up a bot that creates multiple buy orders every time the buying signal is met and closed once the short signal is triggered - and vice versa. It seems to be working in TradingView when I add the strategy to the chart however when I connect it to 3 commas it only takes in one buy order (paper trading account) - and it closes it specifically when the condition to keep the position from closing is triggered.
I think I've set up the strategy correctly to take up to six positions with pyramiding.
strategy("DEMA CROSS STRATEGY", shorttitle = "DEMAC-S", overlay = true, initial_capital = 4000, default_qty_type = strategy.percent_of_equity, default_qty_value = 20, commission_type = strategy.commission.percent, commission_value = 0.03, pyramiding = 6)
The conditions to keep a position from closing if longAction or shortAction are true, then keep the opened positions from closing, otherwise close all positions and open a long/short.
positionState = volume < valueThreshold and ADXsignal < adxThreshold
//logic
longCondition = ta.crossover(DEMA1, DEMA2) and supertrend_X_min < close and mfi+rsi/1.8 > 40 and close > WMA
shortCondition = ta.crossunder(DEMA1, DEMA2) and supertrend_X_min > close and mfi+rsi/1.8 < 60 and close < WMA and atr < .05
longAction = (longCondition and positionState)
shortAction = (shortCondition and positionState)
if (shortAction or longAction)
false
else
if (longCondition)
strategy.entry("Enter Long", strategy.long)
strategy.exit("Exit Short", stop=na)
if (shortCondition)
strategy.entry("Enter Short", strategy.short)
strategy.exit("Exit Long", stop=na)
//
//Buy and sell alerts
buyAlert = XXXXXXXXXXXXXXXXXXXXXXXXXXX
exitAlert = XXXXXXXXXXXXXXXXXXXXXXXXXXXX
if longAction ? na : longCondition
alert(buyAlert, alert.freq_once_per_bar)
if shortAction ? na : shortCondition
alert(exitAlert, alert.freq_once_per_bar)
I've tried multiple different if then statements but honestly I'm not sure if I'm just doing it plain wrong at this stage.
Like I've stated, the code works in TradingView - not in 3Commas

Power BI - Date calculations for a non standard month

Power BI Desktop
Version: 2.73.5586.984 64-bit (September 2019)
I am creating a calculated column to determine if a ticket has been completed in a "Current" or "Backlog" state. Our reporting period month goes from the 26th of the month to the 25th. If a ticket was completed in the reporting period m/26 - m/25 it would be considered "Current." If the ticket was completed outside of that time frame then it would be "Backlog." Also, if the current ticket has not been completed but still has the possibility of being completed in the same reporting period then that would be listed as "Current", but if it goes on to the next reporting month then it would be "Backlog."
Example:
Created 1/1/2021 & Completed 1/10/2021 = Current
Created 1/1/2021 & Completed 3/18/2021 = Backlog
Created 1/25/2021 & Completed 1/26/2021 = Backlog
Created 4/20/2021 & Not Completed & Today [4/30/2021] = Backlog
Created 4/29/2021 & Not Completed & Today [4/30/2021] = Current
I have written the following DAX to handle this but I seem to run into issues after the end/at the start of the reporting period, where the calculations don't work properly and everything lists as either current or backlog.
I also have a helper column in my Date Table that determines what the current reporting period is based on the current day, but I am not using it in this formula, but can if it would make it more efficient.
What is a better/proper way to do this?
Current/Backlog Caluclated Column:
Current_Backlog =
VAR CreatedDay = Day(IR_SR[Created_Date])
VAR CompletedDay = Day(IR_SR[Completed_Date])
VAR CreatedMonth = Month(IR_SR[Created_Date])
VAR CompletedMonth = Month(IR_SR[Completed_Date])
VAR CreatedMonthAdd = Month(IR_SR[Created_Date])+1
VAR CompletedMonthAdd = Month(IR_SR[Completed_Date])+1
VAR CurrentMonth = Month(TODAY())
VAR CurrentMonthAdd = Month(TODAY())+1
VAR CurrentDay = Day(TODAY())
RETURN
//If the date the ticket was completed is before the 26th and the created and completed month match, mark as current
IF(CompletedDay < 26 && CreatedMonth = CompletedMonth, "Current",
//If the completed date is after or equal to the 26th see if the created month plus one and completed month plus one match, mark as current
IF(CreatedDay >= 26 && CompletedDay >= 26 && CreatedMonthAdd = CompletedMonthAdd, "Current",
//If the completed date is after or equal to the 26th and the created date is after or equal to the 26th see if the created and completed month plus one match, mark as current
IF(CreatedDay >= 26 && CreatedMonthAdd = CompletedMonth, "Current",
//If the ticket is not completed and the created date is less then the 26th and the created month and current month match, mark as current
IF(IR_SR[Open/Closed] = "Open" && CurrentDay < 26 && CreatedDay < 26 && CreatedMonth = CurrentMonth, "Current",
//If the ticket is not completed and the created date is greater then the 26th and the created month and current month match plus one, mark as current
IF(IR_SR[Open/Closed] = "Open" && CurrentDay >= 26 && CurrentDay < 1 && CreatedDay >= 26 && CreatedMonthAdd = CurrentMonthAdd, "Current",
IF(IR_SR[Open/Closed] = "Open" && CurrentDay < 26 && CurrentDay >= 1 && CreatedDay >= 26 && CreatedMonthAdd = CurrentMonth, "Current",
"Backlog"))))))
Current Reporting Month:
= Table.AddColumn(#"Inserted Day Name", "Reporting_Period", each if Date.Day([Date]) >= 26
then Date.StartOfMonth(Date.AddMonths([Date], 1))
else Date.StartOfMonth([Date]))
an advice in this case. Compare both DAX formula in the performance analyizer inside Power BI and check how much time spent the calculation.
I guess all your data are imported, in this case data are cached, so first problem about performance is solved.
Anyway, paste second part of your DAX code and I'll check it.
Thanks

Selecting values between dates in Tableau

I started playing with Tableau. My data looks like below.
I want to create Calculated Field that divides my viz by color. I've got problem with dealing with dates. As you can see variable Quarter consists quarters of each year. What I want is to get rid of those gaps. I know my calculated field is done wrong but I tried so many different options and none of them worked. Basically I want each President starts (for example Donald Trump) his president's seat at 01.01.2017 and finishes it at 31.12.2020.
How should I write it to actually work?
IF YEAR([Quarter]) >= 1981 and YEAR([Quarter]) <= 1989 then 'Ronald Reagan'
ELSEIF YEAR([Quarter]) >= 1989 and YEAR([Quarter]) <= 1993 then 'George H. W. Bush'
ELSEIF YEAR([Quarter]) >= 1993 and YEAR([Quarter]) <= 2001 then 'Bill Clinton'
ELSEIF YEAR([Quarter]) >= 2001 and YEAR([Quarter]) <= 2009 then 'George W. Bush'
ELSEIF YEAR([Quarter]) >= 2009 and YEAR([Quarter]) <= 2017 then 'Barack Obama'
ELSEIF YEAR([Quarter]) >= 2017 and YEAR([Quarter]) <= 2021 then 'Donald Trump'
END
The breaks you see in the line aren’t caused by your calculation, but here are two suggestions nonetheless - and some other tips.
Compare against complete dates, either using date literals (enclosed in # signs) or calling a function like MakeDate(). And you can simplify and speed up your calc by taking advantage of the knowledge that prior tests failed - I.e. to not repeat those tests, as shown below.
if [Quarter] < #01/20/1981# then ‘Historical’
elseif [Quarter] < #01/20/1989# then 'Ronald Reagan'
elseif [Quarter] < #01/20/1993# then 'George H. W. Bush'
elseif [Quarter] < #01/20/2001# then 'Bill Clinton'
elseif [Quarter] < #01/20/2009# then 'George W. Bush''
elseif [Quarter] < #01/20/2017# then 'Barack Obama'
elseif [Quarter] < #01/20/2021# then 'Donald Trump'
else ‘Joe Biden’
end
#AniGoyal’s suggestion to make a separate table and use a join is a good idea too, but the join calc won’t look like the one above - hint - it would have 2 tests
As to the gaps between marks ...
After you place this field on the color shelf, try changing its role from dimension to attribute (and back) to see which view you prefer. You could also directly drag the tiles in your color legend to sort them in chronological order.

Tableau - How to calculate date/time difference and result in full date/time?

I'm trying to calculate a difference between connection time and disconnected time. See image below. But DATEPART formula that I'm using only allows me to use one parameter (hour, minute, second,...)
However, as in the image, I have an ID where disconnection at 3/1/17 2:35:22PM and connection back at 3/2/17 1:59:38 PM
Ideal Response: 23 hours, 24 minutes and 16 seconds
but using the formula:
ZN(LOOKUP(ATTR(DATEPART('minute', [Disconnected At])),-1)-(ATTR(DATEPART('minute', [Connected At]))))
it isn't doing the trick.
Could someone help me to achieve my ideal response? Or similar result that would give me the completeness of date and time?
Thank You
Tableau ScreenShot
Use DATEDIFF by seconds between your two dates. Then create a calc field as follows:
//replace [Seconds] with whatever field has the number of seconds in it
//and use a custom number format of 00:00:00:00 (drop the first 0 to get rid of leading 0's for days)
IIF([Seconds] % 60 == 60,0,[Seconds] % 60)// seconds
+ IIF(INT([Seconds]/60) %60 == 60, 0, INT([Seconds]/60) %60) * 100 //minutes
+ IIF(INT([Seconds]/3600) % 24 == 0, 0, INT([Seconds]/3600) % 24) * 10000 //hours
+ INT([Seconds]/86400) * 1000000 // days
for more information, check out this blog post where I got this from. http://drawingwithnumbers.artisart.org/formatting-time-durations/

Tableau: last value calculation in calculated field

my dataset is like this
KPI VALUE TYPE DATE
coffee break duration 11 0 30/06/2015
coffee break duration 12 0 31/07/2015
coffee break duration 10 0 30/11/2014
coffee break duration 10 0 31/12/2014
coffee expense 20 1 31/07/2015
coffee expense 20 1 31/12/2014
coffee consumers 15 -1 31/07/2015
coffee consumers 17 -1 31/12/2014
for Type, 0 means minutes, 1 means dollars and -1 means people
I want to get a table like this
KPI Year(date) YTD
coffee break duration 2015 11,5
coffee break duration 2014 10
....
YTD calculation is:
if sum([TYPE]) = 0 then avg([VALUE])
elseif sum([TYPE]) > 0 then sum([VALUE])
elseif sum([TYPE]) < 0 then [last value for the considered year]
end
By [Last value for the considered year] I mean the last entry available, in a year if my table is set to Year, otherwise it has to change dynamically based on what Timespan I want to show.
What can I do to have [last value for the considered year] as a calc field ready to use in my YTD calc?
Many thanks,
Stefania
If I understand your question, than you can use LOD in the IF statement
if sum(type) = 0 then avg([value])
elseif sum([type]) > 0 then sum(value)
elseif sum([type]) < 0 then max(if [date] = { INCLUDE kpi: max(date)} then [value] end)
end
If there are several values on the last day of the considered year, it would take the biggest value
I slightly modified your data to show that results are working correctly