I've written a report using ColdFusion and SQL, and the queries won't return any rows when a certain value in every row is zero. I'm using a cfstoredproc to retrieve the data, and this is how I'm displaying it:
<cfloop query="DONORS_WITHDRAWN">
<tr>
<td align="left"><cfoutput>#DONORS_WITHDRAWN.Reason#</cfoutput></td>
<td align="right" style="padding-right: 58px"><cfoutput>#DONORS_WITHDRAWN.Number_of_DONOR_withdrawals#</cfoutput></td>
</tr>
</cfloop>
This is how the results look when only some of the values are zero:
And this is how they look when all of the results are zero (no rows are displayed):
When I run the query in SQL Server Management Studio for a time period when all of the results are zero, all of the rows are returned as expected. They just won't appear in the ColdFusion report unless at least one of the values is greater than zero.
Related
I am new to NetSuite and my current role. Our warehouse team is strunggling with Picking Tickets coming through with zero quantity items among a long list of items to be picked.
Pickers are making mistakes and picking items for which an order has not been placed. The original problem is with the Sales Order which is being worked on by others.
I am trying to find a quick solution whereby when picking tickets are printed the zero quantity items are filtered out and not printed.
Really appreciate any help provided.
Try this "SHOW UNCOMMITTED ITEMS ON PICKING TICKETS"
Navigation: setup--> Accounting-->Accounting preferences-->order management
If anyone else comes across this, you can also add this code to the PDF template in the case where you still need the uncommitted line items in Netsuite but just not printed on the PDF:
<thead>
<tr>
<th>...</th>
<tr/>
</thead>
<!-- only line items with qty > 0 on Sales Order will print -->
<#if item.quantity gt 0>
<tr>
<td>...</td>
</tr>
</#if>
I am a beginner in power BI. I have to create a report with share point data. I have imported the data into dataset. However, some columns have text with html table tags or style like below -
<div class="ExternalClass5DA0D04953B047459697675F266FEABF">
<p></p>
<table width="395" border="0" cellspacing="0" cellpadding="0" style="width:296pt;">
<tbody>
<tr height="115" style="height:86.4pt;">
<td width="395" height="115" class="xl64" style="width:296pt;height:86.4pt;">
I am working on issue. I shall update the progress. <br>
</td>
</tr>
</tbody>
</table>
<p><br></p>
</div>
But I would like to show the plain text only which is "I am working on issue. I shall update the progress."
From this community thread, you can find a handy function for stripping all the HTML tags:
Here's the core logic (ignoring the documentation metadata for readability):
let func = (HTML) =>
let
Check = if Value.Is(Value.FromText(HTML), type text) then HTML else "",
Source = Text.From(Check),
SplitAny = Text.SplitAny(Source,"<>"),
ListAlternate = List.Alternate(SplitAny,1,1,1),
ListSelect = List.Select(ListAlternate, each _<>""),
TextCombine = Text.Combine(ListSelect, "")
in
TextCombine
in
func
Having this handy bit of code, create a new blank query and paste the above code into the advanced editor and give it a name, say, TextFromHTML.
Once you have that function defined, you can use it in any of your queries. For example, here's what a step to transform the column ColWithHTML might look like:
Table.TransformColumns(#"Prior Step", {{"ColWithHTML", each TextFromHTML(_), type text}})
You can create a new column with below formula as show below
if [HMTLField] = null then null else Html.Table([HMTLField] , {{"text",":root"}})
Then click on the button on right top of the field to convert this field as text by expanding it.
I am sending a HTML string to the Cold Fusion (9) server. The string contains a HTML table with multiple rows. Since the table doesn't have a head I need to change the <td>s of the first row into <th>s.
For your information:
The code to change is a paste code coming from MS Word. The code gets sent to the server to check if there are any tables in it. If yes, there is an option dialog shown to the user where he can descide how the table will be formatted (striped, hovers and so on).
In my opinion the best way to do that would be ReReplace(). But I can't figure what the right regex can be.
Any suggestions on that will be much appreciated.
The code looks like:
<table class="table">
<tbody>
<tr><td>Head 1</td><td>Head 2</td><td>Head 3</td></tr>
<tr><td>Content 1 Row 1</td><td>Content 2 Row 1</td><td>Content 3 Row 1</td></tr>
<tr><td>Content 1 Row 2</td><td>Content 2 Row 2</td><td>Content 3 Row 2</td></tr>
</tbody>
</table>
And should look like:
<table class="table">
<tbody>
<tr><th>Head 1</th><th>Head 2</th><th>Head 3</th></tr>
<tr><td>Content 1 Row 1</td><td>Content 2 Row 1</td><td>Content 3 Row 1</td></tr>
<tr><td>Content 1 Row 2</td><td>Content 2 Row 2</td><td>Content 3 Row 2</td></tr>
</tbody>
</table>
Thanks in advance.
Obligatory warning: maybe a parser or as #npinti suggested changing the output in the first place is a far better way to go.
That being said, you could use a lazy quantifier (expensive!) between the <td> tags and feed the function chunks of <table> parts and substitute it with <th>\2</th> (see the regex 101 demo for an example).
(<td>(.*?)<\/td>)
Hint: This does not take additional attributes into account (e.g. class="test123").
I have an easy question. I'm trying to use coalesce in combination with a group by clause. I want to get 0 values when the variable is null. Here is my sql server code:
SELECT SUM(COALESCE(NETTOTAL,0)) AS NETTOTAL,DATEPART(MM,RECORD_DATE) MONTH
FROM ORDERS WHERE ORDER_EMPLOYEE_ID=#attributes.record_emp_id#
GROUP BY DATEPART(MM,RECORD_DATE) ORDER BY MONTH
.. and my output:
<tr height="20">
<td>Orders</td>
<cfoutput query="get_orders"><td style="text-align:center;">#tlformat(nettotal,2)# - #month#</td></cfoutput>
</tr>
This code is just for the orders. There is also the sales row. Anyway here is the screenshot to make it more clear:
http://i.stack.imgur.com/VIAmr.png
To make it more clear I added the number of the month. As you can see the order is broken since there are no zero values for the other months...
P.S.Thank you all for the help! i really appreciate it!
Your query is not at fault. You are trying to select from ORDERS based on each employee_id. You are then looping over it.
If a given month has no orders, then there will be no row for it within the result set.
Even if there were only orders for the last 4 months, they would get pushed to the first 4 as you are not checking that the month you are currently outputting matches the column header.
For a bit of metacode, I would go down this route
1 - create an array as follows
arrMonths= [
{orders=0,sales=0},
{orders=0,sales=0}....
]
This will give you a stc you can iterate over later.
2 - I would then loop over each query
<cfoutput query="get_orders">
<cfset arrMonths[month].orders = nettotal>
</cfoutput>
3 - I would then iterate over the array
<tr height="20">
<td>Orders</td>
<cfoutput from="1" to="#ArrayLen(arrMonths)#" index="thisMonth">
<td style="text-align:center;">#tlformat(arrMonths[thisMonth].orders,2)# - #thisMonth#</td>
</cfoutput>
</tr>
This way, every month will ALWAYS have a value even if it's 0. You can also ditch the coalesce as the simple fact that rows with no orders have no records means they default to 0 so your query may become
SELECT
SUM(COALESCE(NETTOTAL)) AS NETTOTAL,
DATEPART(MM,RECORD_DATE) MONTH
FROM ORDERS
WHERE ORDER_EMPLOYEE_ID=<cfqueryparam cfsqltype="cf_sql_integer" value="#attributes.record_emp_id#">
GROUP BY DATEPART(MM,RECORD_DATE)
MONTH is now not necessary as it's just inserting into the array which deals with ordering
TRy ISNULL() Instead of COALESCE .
COALESCE is used for multiple argumentsif multiple arguments are not needed you could use ISNULL
Try to invert the order of the functions Sum and Coalesce.
IsNull might be more readable as well:
SELECT IsNull(SUM(NETTOTAL), 0) AS NETTOTAL,
DATEPART(MM, RECORD_DATE) MONTH
FROM ORDERS
WHERE ORDER_EMPLOYEE_ID = #attributes.record_emp_id#
GROUP BY DATEPART(MM, RECORD_DATE)
ORDER BY MONTH
If there are no elements of NETTOTAL, Coalesce from your code would not be called. So a Sum of no rows will be null.
I have a query which retrieves Some data.
I want to display that data considering some conditions in different div tags.
Now my question is,
I am doing this by looping the query once and getting the data in three different structs and using these structs while displaying. Is this a good approach or
looping through the query everytime in each div to check the condition is the rirht approach ?
<tr >
<td >
features:
</td>
<td >
<cfloop query="getAttributes">
<cfif getAttributes.type_id EQ 1>
#getAttributes.seat#<br>
</cfif>
</cfloop>
</td>
</tr>
<tr>
<td >
Disclosures:
</td>
<td >
<cfloop query="getAttributes">
<cfif getAttributes.type_id EQ 2>
#getTicketAttributes.seat#<br>
</cfif>
</cfloop>
</td>
</tr>
Or can i use the below approach
seatStruct
disclosureStruct
<cfloop query="getAttributes">
<cfif getAttributes.type_id EQ 1>
Insert seatStruct
<cfelseif getAttributes.type_id EQ 2>
insert disclosureStruct
</cfif>
Now use these structs to display
I think you'll have to edit your question a little bit, put some example.
Less looping is always the best approach :)
Less conversion if not necessary is best approach :)
If your data is in one query, than there's no need to loop more than once, I guess...
The best approach will always depend on your specific problem.
Although fewer loop iterations will always result in faster performance, sometimes it can be acceptable to sacrifice some performance for the sake of improved readability.
Maintenance costs are usually the most expensive part of software, so it is worthwhile to make your code easy to read.
In this specific case:
Unless the getAttributes query result is unusually large (like over
10000 rows) or this page is loaded unusually often (like more than
once/sec), it probably won't make a noticeable difference how many
times you loop over it.
Both options will take exactly the same amount of time, anyways: The first option loops over the query twice. The second option loops through the query once to populate two structs, then your display code loops through each of the generated structs (which combined have the same number of elements as the query has rows), resulting in the same exact number of total iterations (equivalent to getAttributes.recordcount*2).
The code that splits the query results up into different structs is somewhat unusual, thus decreasing readability and increasing maintenence costs. Since it doesn't actually improve performance, it is entirely counter-productive and should not be used.