how to use wildcard in Crystal report selection expert - crystal-reports

i found this on another forum
set your default value 'ALL' for parameter
add if statement to Select Expert:
If {?Parameter}='ALL'
Then {Database.Field} like '*'
Else {Database.Field} = {?Parameter} and
{fctime_ts} >= {#StartDate} and
{fctime_ts} < {#EndDate}
that didnt work, for some reason it isnt using the date constraints. So then i tried the following.
{fpartno} = IIF({?PartNbr} = 'All', '*' , {?PartNbr})
that works great if i use an actual part number, but when i use the defaul ALL it doesnt work at all.
this is my complete selection formula:
fpartno} = IIF({?PartNbr} = 'All', '*' , {?PartNbr}) and
{fctime_ts} >= {#StartDate} and
{fctime_ts} < {#EndDate}
anyone know how to either make the mentioned answer on this forum work with dates or how ot make this way work?

Try:
(If {?Parameter}='ALL' Then
{Database.Field} LIKE '*'
Else
{Database.Field} = {?Parameter}
)
and {fctime_ts} >= {#StartDate}
and {fctime_ts} < {#EndDate}

I had a problem with what you recommended, but i found this answer.
This is how it works, it checks to see if PartNbr is equal to 'All'. If it does then it skips to the date restraints. By skipping, it will in turn select all the parts in that date range. if PartNbr doesn't equal 'All', it will take PartNbr and get the parts with that number within the date range.
This solution worked great for me, just htought id update if someone came by
({?PartNbr} = 'All'
or
{?PartNbr}= {intran.fpartno}) and
{intran.fctime_ts} >= {#StartDate} and
{intran.fctime_ts} <= {#EndDate}

Related

Manipulating last two rows if there's data based on a Cut date

This question is a slightly varied version of this one...
Now I'm using Measures instead of Calculated columns and the date is static instead of having it based on a dropdown list.
Here's the Power BI test .pbix file:
https://drive.google.com/open?id=1OG7keqhdvDUDYkFQFMHyxcpi9Zi6Pn3d
This printscreen describes what I'm trying to accomplish:
Basically the date in P6 Update table is used as a cut date and will be fixed\static. It's imported from an Excel sheet where the user can customize it however they want.
Here's what should happen when a matching row in Test data table is found for P6 Update date:
column Earned Daily - must have its value summed with the next row if there's one;
column Earned Cum - must grab the next row's value;
all the previous rows should remain intact, that is, their values won't change;
all subsequent rows must have their values assigned 0.
So for example:
If P6 Update is 1-May-2018, this is the expected result:
1-May 7,498 52,106
2-May 0 0
If P6 Update is 30-Apr-2018, this is the expected result:
30-Apr 13,173 50,699
1-May 0 0
2-May 0 0
If P6 Update is 29-Apr-2018, this is the expected result:
29-Apr 11,906 44,608
30-Apr 0 0
1-May 0 0
2-May 0 0
and so on...
Hope this makes sense.
This is easier in Excel, but trying to do this in Power BI is making me go nuts.
I will ignore previously asked related questions and start from scratch.
First, create a measure:
Current Earn =
CALCULATE (
SUM( 'Test data'[Value]),
'Test data'[Act Rem] = "Actual Units",
'Test data'[Type] = "Current"
)
This measure will be used in other measures, to save you from typing all these conditions ("Actual Units" and "Current") again and again. It's a great practice to re-use measures in other measures - saves work, makes code cleaner and easier to refactor.
Create another measure:
Cut Date = SELECTEDVALUE('P6 Update'[Date])
We will use this measure whenever we need a cut off date. Please note that it does not have to be hard-coded - if P6 table contains a list of dates, you can create a pull-down slicer from the dates, and can choose the cut-off date dynamically. The formula will work properly.
Create third measure:
Next Earn =
VAR Cut_Date = [Cut Date]
VAR Current_Date = MAX ( 'Test data'[Date] )
VAR Next_Date = Current_Date + 1
VAR Current_Earn = [Current Earn]
VAR Next_Earn = CALCULATE ( [Current Earn], 'Test data'[Date] = Next_Date )
RETURN
SWITCH (
TRUE,
Current_Date < Cut_Date, Current_Earn,
Current_Date = Cut_Date, Current_Earn + Next_Earn,
BLANK ()
)
I am not sure if "Next Earn" is a good name for it, hopefully you will find a more intuitive name. The way it works: we save all necessary inputs into variables, and then use SWITCH function to define the results. Hopefully it's self-explanatory. (Note: if you need 0 above Cut Date, replace BLANK() with 0).
Finally, we define a measure for cumulative earn. It does not require any special logic, because previous measure takes care of it properly:
Cum Earn =
VAR Current_Date = MAX('Test data'[Date])
RETURN
CALCULATE(
[Next Earn],
FILTER(ALL('Test data'[Date]), 'Test data'[Date] <= Current_Date))
Result:

MDX Calculated member filter by dimension attribute and member value

I have MDX (similar to one questioned and answered here):
(
[PX Market].[PX MARKET NAME].&[Elbas],
[Measures].[PX QUANTITY]
)
It works for me (it filters measures to value "Elbas" only). But I need another filtering - to have only values which are < or > than 0. There shoud be some condition similar to "[Measures].[PX QUANTITY] < 0". But I do not know how to implement it.
Thank for any of your advice.
Ondra
Table looks similar like this:
PX_MARKET_NAME; PX_QUANTITY
Elbas; 5
Elbas; -3
Elspot; 4
In result I need only 2nd value (-3). Which belongs to Elbas and is smaller then 0.
So far I tried this, but it is now working :(
FILTER
(
[PX Market].[PX MARKET NAME].&[Elbas],
[Measures].[PX PURCHASE]
) < 0
Try that:
IIF(
([PX Market].[PX MARKET NAME].&[Elbas],[Measures].[PX QUANTITY]) < 0,
([PX Market].[PX MARKET NAME].&[Elbas],[Measures].[PX QUANTITY]),
NULL
)

Summing Only Visible Rows in SSRS

I'm trying to sum only the visible rows for a report and I know the format is:
=Sum( iif( <use the condition of the Visibility.Hidden expression>, 0, Fields!A.Value))
In my report, I've set row visbility to:
=IIF(CInt(Fields!EM_ET.Value)=1 Or CInt(Fields!EM_ET.Value)= 2,True,False)
Not exactly sure what I'm missing, but when I use this as an expression:
=Sum(IIF(CInt(Fields!EM_ET.Value)=1 Or CInt(Fields!EM_ET.Value)= 2,True,False),0,Fields!EM_ET.Value)
I get this following error: Value expression for textrun'FTD1.Paragraph[0].TextRuns[0]' has a scope argument that is not valid for aggregate function.
You are giving the True/False as output to the SUM() from your expression.You need to change your expression as,
=Sum(IIF(CInt(Fields!EM_ET.Value) = 1 Or CInt(Fields!EM_ET.Value)= 2,0,Fields!EM_ET.Value))
Thanks coder of code.
I am getting some error message if i am using '0', so i replaced with nothing it's working. I thought it would be helpful.
=SUM(IIF(ISNOTHING(Fields!value1.Value) OR ISNOTHING(Fields!value2.Value),NOTHING,Fields!value1.Value))
I was having similar issues. I know this question has a marked answer, however it isn't entirely correct.
The following contains the code from the "marked correct" answer:
=Sum(IIF(CInt(Fields!EM_ET.Value) = 1 Or CInt(Fields!EM_ET.Value) = 2,0,Fields!EM_ET.Value))
The following snipit of code contains the code from above, with a slight tweak:
=Sum(IIF(CInt(Fields!EM_ET.Value) = 1 Or CInt(Fields!EM_ET.Value) = 2,NOTHING,Fields!EM_ET.Value))
By changing the "0" to "NOTHING" this will resolve any lingering issues with your formula. The formula I was having issues with was returning "#Error" in the cell that was supposed to return the sum of the visible cells in the column within the row group.
My formula originally looked like this:
=IIF(Sum(Fields!VCBitType.Value) <> 0 OR (Parameters!Details.Value = "Detail"), Sum(IIF((Fields!VCBitType.Value = 0) and (Parameters!Details.Value = "Dangerous"),0,Fields!VC.Value)), "")
I altered my formula after seeing Hari's comment above:
=IIF(SUM(Fields!VCBitType.Value) <> 0 OR (Parameters!Details.Value = "Detail"), SUM(IIF((Fields!VCBitType.Value = 0) and (Parameters!Details.Value = "Dangerous"),NOTHING, Fields!VC.Value)), "")
I wanted to set the cells value to "" (empty) rather than hide the cell entirely or set that cell's value to "0" in my report (due to the fact that not displaying the cell entirely made the report look really funky). Because I did this, using a "0" in my formula conflicted with the value of the cell which was "" (empty), causing the formula to break. The only change I made was to alter "0" to "Nothing", this resolved the issue I was having with the cell's formula.

Suppressing Section in Crystal reports

I have a section in my report and Below is my requirement to suppress it:
If scanmode and status=null (these fileds coming from database)
then i need to suppress the section.
If it is not null then i need check next condition {Status.status} >= 3 if it is >=3 then i need to check next condition {?Stack} <> "S" .
Please suggest the logic i wrote is correct or not>If wrong please modify it
Logic i wrote:
isnull({Status.scan_mode}) and isnull({Status.status})
or
{Status.status} >= 3
or
{?Stack} <> "S"
What is my doubt is here we gave or condition for every logic will it check 1st condition,if it is true then then 2nd ,if it is true then 3rd
or it will hide the section if any one of above 3 logic's is correct.
Is there any way to convert above logic to if else condition.Can we write if else in suppress condition.If yes please tell me
Please suggest me.
Write below logic in supress section
If isnull({Status.scan_mode})
then
(
if isnull({Status.status}) or {Status.status} >= 3 then
(
if {?Stack} <> "S"
then
true
)
)
else false
if isnull({Status.scan_mode}) and isnull({Status.status}) then true
else if Scanmode = 'C' or Scanmode = 'D' then true
else if {Status.status} >= 3 or {?Stack} <> "S" then true
else false
I hope this helps

Making a progress bar change a UILabel?

I am attemping to try and make a progress bar change a UILabel every .15 of the progress bar to a different phrase could anyone help me out with this?
I have tried using "if" statements i.e if prog.progress = .15 UIlable.text = #"Fire!" but everytime I do a higher progress number it just replaces the UILabel with that text.
Does anyone know an easier method for doing this?
Thanks for your help.
You could do something like a lookup of a string based on the progress. There are lots of ways to do this, simplest maybe to understand is a if/then/else tree.
if (prog.progress < .15)
label.text = #"msg1";
else if (prog.progress >= .15*1 && prog.progress < .15*2)
label.text = #"msg2";
else if (prog.progress >= .15*2 && prog.progress < .15*3)
label.text = #"msg3";
Warning, didn't compile above code, but something along those lines should work.
DavidNeiss is correct. Make sure you are using == and not =. = is the assignment operator and == is used to test. Also, checking if a value is exactly .15 probably isn't that realistic if it is continuously raising and your program might skip that catch. you should be using < and > to say if it is this range, then do this. If it is in this range, do this.