I am creating a crystal report in which i have to ![enter image description here][1] show address in this format for every school
ADD1
ADD2
ADD3
CITY
DIST
PINCODE
and i am fetching data from database, all the above column have some NULL values in it like for SCHOOL A - ADD1,ADD2,ADD3 have NULL values and for school B ADD2,ADD3 and CITY have NULL values and same like rest schools have some null values now when i am writing formula for first school
IF ISNULL({TEMP_PAY.ADD1})THEN
(
IF ISNULL({TEMP_PAY.ADD2}) THEN
(
IF ISNULL({TEMP_PAY.ADD3})THEN
(
IF ISNULL({TEMP_PAY.CITY})THEN
(
IF ISNULL({TEMP_PAY.DIST})THEN
{TEMP_PAY.PIN}
ELSE
{TEMP_PAY.DIST}
)
ELSE
{TEMP_PAY.CITY}
)
ELSE
{TEMP_PAY.ADD3}
)
ELSE
{TEMP_PAY.ADD2}
)
ELSE
{TEMP_PAY.ADD1}
then the first address of all the schools are showing correct but when i put same formula with other parameters then first Scool give duplicate CITY and rest scool are the same and some gets correct
i want that where there is NULL it should escape the field and give the next field which have some value for the all above fields help me for the same as soon as possible as i have searched lot for the same issue but did not get any help....
Regards
Sanjeev
To the extent I understood your problem.... try below solution.
Since you are looking to pick next value if present value is NULL then you can use function NEXT.
IF ISNULL({TEMP_PAY.ADD1})THEN
NEXT({TEMP_PAY.ADD1})
ELSE IF ISNULL({TEMP_PAY.ADD2}) THEN
NEXT({TEMP_PAY.ADD2})
ELSE IF ISNULL({TEMP_PAY.ADD3})THEN
NEXT({TEMP_PAY.ADD3})
ELSE IF ISNULL({TEMP_PAY.CITY})THEN
NEXT({TEMP_PAY.CITY})
ELSE IF ISNULL({TEMP_PAY.DIST})THEN
NEXT({TEMP_PAY.DIST})
ELSE
NEXT({TEMP_PAY.PIN})
Let me know if it helps
Related
i have created a query that returns users who placed order in a specific month and after how many months they have returned. the problem is when there's no user placed any order in a month it returns blank . I want to return zero instead .
I created a case statement as :
case when user_id is null then 0 else user_id end
I also tried:
case when user_id is null and delivery_month is null and returned_month is null then 0 else user_id end
if there's no row evaluated for the user, how can i replace that with 0 ?
this is how blank values looks like when I loaded data in the visualization tool:
I have to insert data to db in form fields that have the same path and i want to save it different id's but rather it concatenated it with ",", how could i possibly do it?
I tried to make some alias in SQL but it saves into same db field name with concatenated with ","
i expected in db when i insert that
EX.
db field name = description
input 1 value = "john";
input 2 value = "doe";
id description
1 john
2 doe
above is my expected result
but in my case when i insert it shows these
id description
1 john,doe
can someone help me to achieve that result ? THANKYOU!
Let me present a similar situation. You have a database of people and you are concerned that each person might have multiple phone numbers.
CREATE TABLE Persons (
person_id INT UNSIGNED AUTO_INCREMENT,
...
PRIMARY KEY(person_id) );
CREATE TABLE PhoneNumbers (
person_id INT UNSIGNED,
phone VARCHAR(20) CHARACTER SET ascii,
type ENUM('unknown', 'cell', 'home', 'work'),
PRIMARY KEY(person_id, phone) );
The table PhoneNumbers has a "many-to-1" relationship between phone numbers and persons. (It does not care if two persons share the same number.)
SELECT ...
GROUP CONCAT(pn.phone) AS phone_numbers,
...
FROM Persons AS p
LEFT JOIN PhoneNumbers AS pn USING(person_id)
...;
will deliver a commalist of phone numbers (eg: 123-456-7890,333-444-5555) for each person being selected. Because of the LEFT, it will deliver NULL in case a person has no associated phones.
To address your other question: It is not practical to split a commalist into the components.
I am working on Tableau server but I believe the problem I am facing does not correspond to tableau server specifically.
I am using two data sources ds1 and ds2 which are joined using the dimension Id . ds1 has a field city and ds2 has a field district. There is only 1 city corresponding to each Id but there can be multiple district corresponding to an Id .
I have created a calculated field Points in ds2 which is described in the code segment.
I have researched from different sites and blogs (including tableau support). I came to a close possible reason behind this and I might be wrong . The ATTR function which works on row level and identify if a row is unique then it outputs the dimension otherwise it outputs '*' . I think when I joined those two tables the district dimension in ds2 might have the '*' instead of actual district values, so it might not be able to compare the conditions in if statements of Point .
//Point//
IF [city] == "Delhi"
AND [district] == "Dist1"
AND [district] == "Dist2"
THEN "100 Section"
ELSEIF [city] == "Mumbai"
AND [district] == "Dist11"
AND [district] == "Dist12"
THEN "200 Section"
ELSE "Other Section"
END
When I insert data which satisfy the conditions in calculated field, it is going in Other section of the Point .I want it to go in desired section.
For instance
Id = 19
city = Delhi
district = Dist1
district = Dist2
district = Dist3
It should go in 100 Section but it is going in Other Section . What modifications should I do or add to make the Point work properly ?
in PowerPivot, I am struggling to find information on matching values in the same column.
I would like to display the matching name in the below table, e.g. for John with ID '1' it would be Peter (also with ID '1'), for Jack (ID '2') it would be Mary (also ID '2'), etc.
I have been able to 1) find the number of occurrences using:
=COUNTX(FILTER (Table2, (EARLIER ( [ID] ) = [ID] )),Table2[Name])
...also, I was able to add up the matching values with
=SUMX(FILTER (Table2, (EARLIER ( [ID] ) = [ID] )),Table2[Name])
...but was unable to display 'Peter' in the row of 'John' and 'John' in the row of Peter.
I am assuming it is possible, not sure how...any help would be much appreciated!
OK, I found a solution (thanks to TomMartens on the Power BI blog), it is CONCATENATEX, working exactly the same as SUMX or COUNTX).
Thanks everyone!
In Crystal Reports, is it possible to have a function that returns a numeric value if the if statement evaluates to true and returns NULL otherwise?
I currently have
IF ({INDICATOR} = 'Y') Then
(
{numeric value}
)
Else
(
0
);
But since 0 is a possible value of {numeric value} it doesn't make sense. Rather, I would rather have that field come up blank if the indicator isn't 'Y', but when I replace the 0 with NULL it gives me a type mismatch error.
Is there a way for me to only show the value when the indicator is 'Y'?
If you truly want a null value and not empty try the following
create a formula called NULL then save it and close without entering any data in the formula area. Then in your formula above try
If {INDICATOR} = 'Y' then {numeric value}
else tonumber({#NULL})
you can't return two different datatypes in a single if statement..If if is number then else should also be number.. instead try to split the statements and try.. something like below.
IF ({INDICATOR} = 'Y') Then
(
ToText({numeric value})
)
Else if ({INDICATOR} <> 'Y') Then
(
""
);
If {INDICATOR} = 'Y' then {numeric value}
else {Command.NULLCOL}
The setup in Database Expert is to use Add Command with sql:
select null as nullcol
from dual
Then left join to it.
A returned null value can be very powerful, so your need for a null value should not be questioned. Null values automatically display differently to stand out. Compared to 0 or "", null values work correctly with DistinctCount function. Null values also work correctly with section summaries and crosstabs, which can save you a lot of work which is the whole point of using crystal.