RDLC Report Merge 2 Rows In 1 Row NAV 2013 - dynamic

I have a question about RDLC Report in NAV 2013
I have 2 rows like this
Store10 2.00 5.00 0.00 0.00
Store10 0.00 0.00 3.00 9.00
And I want 1 row by merging these, like;
Store10 2.00 5.00 3.00 9.00
How can it possible ?
Thanks for your answers.

First of all,
If rows first column is unique for your data. You should Group On this field in Visual Studio .
I couldn't add an image for reputation..
After that, Your line will shown merged. So, values maybe missing.
For calculating values effectively, You must use SUM(Field) syntax in "Table Cell Expression"
Like That
=SUM(Fields!RecNo.Value)

Related

SQL Help, Splitting Tax by Tenders

I have a Point of Sale system where all checks and tender details exist in a single table. I'm trying to write a SQL query in a way that I can see check totals by tenders to reconcile with cash flow and bank statements. Unfortunately the schema is not mine and can't change it.
One problem I ran into is that there are cases where one check has multiple transactions involving various tenders, therefore I need to do implement (business set) rules to allocate taxes evenly. Those rules might change in the future to say, allocate taxes to CC first if any, so I need to built in some flexibility.
The SQL table looks like this:
CheckID
LineType
TenderName
LineTotal
Tax
1
ItemSold
5.00
0.25
1
TenderTotal
Cash
5.25
2
ItemSold
10.00
0.50
2
TenderTotal
Cash
5.00
2
TenderTotal
VISA
5.50
3
ItemSold
10.00
0.25
3
ItemSold
10.00
0.25
3
TenderTotal
AMEX
10.25
3
TenderTotal
VISA
10.25
4
ItemSold
10.00
0.50
4
TenderTotal
Cash
20.00
4
TenderTotal
Cash
-9.50
The resulting report needs to have one row per tender, with tax equally distributed among check tenders, and net revenue being the difference between total sale and tax.
TenderName
TotalSale
NetRevenue
TaxCollected
Cash
20.75
19.75
1.00
VISA
15.75
15.25
0.50
AMEX
10.25
10.00
0.25
I tried using Select with Exists, also CTE and recursive CTEs, but can't quite figure it out how to do the tax part cleanly. Any other SQL tricks I could try?
We are using SQL Server 2012 at the moment, but have plans in plan to upgrade to 2016 in the near future.
I don't know if the logic is right, but it gets you the results you are after:
WITH Tenders AS(
SELECT V.CheckID,
V.LineType,
V.TenderName,
V.LineTotal,
SUM(CASE WHEN V.TenderName IS NULL THEN V.Tax END) OVER (PARTITION BY V.CheckID) AS Tax
FROM (VALUES(1,'ItemSold',NULL,5.00,0.25),
(1,'TenderTotal','Cash',5.25,NULL),
(2,'ItemSold',NULL,10.00,0.50),
(2,'TenderTotal','Cash',5.00,NULL),
(2,'TenderTotal','VISA',5.50,NULL),
(3,'ItemSold',NULL,10.00,0.25),
(3,'ItemSold',NULL,10.00,0.25),
(3,'TenderTotal','AMEX',10.25,NULL),
(3,'TenderTotal','VISA',10.25,NULL),
(4,'ItemSold',NULL,10.00,0.50),
(4,'TenderTotal','Cash',20.00,NULL),
(4,'TenderTotal','Cash',-9.50,NULL))V(CheckID,LineType,TenderName,LineTotal,Tax))
SELECT T.TenderName,
SUM(T.LineTotal) AS TotalSale,
SUM(T.LineTotal - T.Tax) AS NetRevenue,
SUM(T.Tax) AS TaxCollected
FROM Tenders T
WHERE T.TenderName IS NOT NULL
GROUP BY T.TenderName;

Is there a way to calculate a dynamic column in SQL based on multiple other columns

I am trying to determine if something is possible to do in SQL where I am creating a view for users and I need to create a column that would state whether or not a line number is "Open" or "Closed". The trouble is that the process to determine that value is based on multiple factors/values of other columns from the source table. Take a look at some data that the view currently generates.
Line # Req_Qty Rej_Qty Adj_Qty Alt_Qty Shipped Cxl Rec Conf
Line 1 71.00 0.00 100.00 0.00 100.00 0.00 100.00 100.00
Line 2 23.00 0.00 0.00 0.00 23.00 0.00 0.00 0.00
Line 3 11.00 0.00 10.00 0.00 10.00 0.00 0.00 0.00
Line 4 12.00 12.00 0.00 0.00 0.00 0.00 0.00 0.00
Line 5 0.00 0.00 0.00 20.00 20.00 0.00 0.00 0.00
In the table above the way the determination is made is as follows:
If there is any value > 0 in Adj_Qty, then the Adj_Qty(Adjusted Qty) effectively becomes the Req_Qty(Requested Qty). If both the Req_Qty and the Adj_Qty are 0 and the Alt_Qty >0, then that now becomes the real Req_ Quantity. So basically, my first comparison is Adj->Req->Alt. Whatever that quantity is would then be reduced by the Rej_Qty(Rejected) or the Cxl_Qty(Cancelled) which results in a balance.
Finally, if the quantity in either the Rec or Conf columns matches that balance, then the line # is closed. So, for the table, Lines 1 and 4 would be closed, 2, 3, and 5 would be open. Is there any way to create a field/column in SQL that would be able to assign "Open" or "Closed" based on that type of logic?
You can use the CASE clause to compute the balance and the status in the view. For example:
create view v as
select *,
case when (
case when adj_qty > 0 then adj_qty
when req_qty > 0 then req_qty
when alt_qty > 0 then alt_qty
else 0.0
end
- rej_qty
- cxl_qty
) in (rec, conf) then 'closed'
else 'open' end as status
from t
I probably didn't understand all the details of your specific logic but this query should be pretty close to what you need. Tweak as needed.

Excel 2007 Calculations

I have a Excel sheet, one date column with different description and values. How can I calculate the sum of the values for each dates using formula not pivot table?
I need summary as shown below:
Date Jun-15 Jul-15
1 175.00 200.00
2 100.00 75.00
3 200.00 175.00
4 60.00 70.00
5 20.00 225.00
6 80.00 50.00
You can use a simple SUMIF() formula:
Hi you can try this to solve your problem. Please let me know it this resolves your query.

Using multiple tables to find cost by transactiondate and location

I am trying to create a query that joins 3 tables with multiple prices and locations. Ex of the data I'm pulling.
Table A - product, product name
Table B - transactionid, date, product, returnreason, quantity, costprice, costamount,
location, journalid
Table C - price1, price2, price3, price4, price5, price6, product, activedate
Table C is updating prices for our products and can be the same from one date to another, or completely change depending on the market. Location in Table B can be up to four different locations.
Ex. Table C (each product is setup basically the same in the tables.)
product price1 price2 price3 price4 price 5 price6 activedate
A 0.00 0.00 0.00 0.00 0.00 0.00 1/1/11
A 0.00 0.00 0.00 0.00 0.00 0.00 2/1/11
A 1.00 0.00 0.63 0.00 1.20 0.20 1/1/12
A 1.20 0.53 0.01 1.00 0.42 0.00 4/1/13
Table B
product transactionid tdate returnreason quantity costprice costamount location journalid
A 00001 5/1/11 def 100 2.00 2.50 100 000010
B 00205 6/13/11 col 250 10.00 15.00 300 000320
A 00207 4/11/13 col 50 5.00 1.50 100 000720
I need to get the information out by the most current price for the item by date. So if I need a yearly report, I can see that for product A - price1 for 1/1/13-4/30/13 was 1.00 and for 5/1/13-present the price is now 1.20.
I have tried many things including sub queries and the latest (which is closest) to limit it by creating a where statement to be activedate<=tdate which will bring me every active date below and equal to the tdate. For this please assume product A is at location 100. How can I limit to the product active during the time frame it would be active?
Most recent...
I added line number in to make sure I got each line of the journal in...just visual.
select distinct(b.transactionid), b.tdate, b.linenum b.product, b.location,
b.journalid, c.price1, c.price2, c.price3, c.price4, c.price5, c.activedate
from Table b inner join
Table c on c.product=b.product
where c.activedate <= b.tdate
When I run this I get all dates that were less than the transaction date, but I need specific. For example the first transaction in my example, it happened on 5/1/11, when I run the query it will give me the results from table c for 1/1/11 and 2/1/11. I just need the date of the price for when the transaction took place.

SQL get the next rows value into current row

I am trying to get the next row's 'alignment' value and store it into the current row in a field called nextAlign. I have tried using grouping and also the unique identifier for this table is not consistent and doesn't always have an increment of 1. Here is some data:
type field starttop startleft length decimals alignment
-------------------------------------------------------------------------------------------
Text CUSTOMER DETAILS CONFIRMATION 13.00 38.00 30.00 0.00 Centre
Text Please spare a few minutes to 15.00 2.00 30.00 0.00 Left
Text confirm your details as held 15.00 2.00 30.00 0.00 Wrap
Text on our system. You may fax the 15.00 2.00 30.00 0.00 Wrap
Text form to the number above. 15.00 2.00 30.00 0.00 Wrap
Text Any information you may supply 17.00 2.00 30.00 0.00 Left
Text will not be made available to 17.00 2.00 30.00 0.00 Wrap
Text third parties according to the 17.00 2.00 30.00 0.00 Wrap
Text Privacy Act. 17.00 2.00 30.00 0.00 Wrap
Text Legal name: 20.50 2.00 30.00 0.00 Left
All I want is a column called 'nextAlign' that has the following data:
nextAlign
-Left
-Wrap
-Wrap
-Wrap
-Left
-Wrap
You didn't specify your DBMS, so this is ANSI SQL:
select type,
field,
align,
lead(align) over (order by starttop) as next_align,
starttop,
startleft
from the_table
use ROW_NUMBER() OVER(ORDER BY )
and outer join it to the same select this way: select_1_rownumber = select_2_rownumber+1
with temptable as
( select rownum
,type
,field
,starttop
,startleft
,length
,decimals
,alignment
from YOURTABLE )
select t.type
,t.field
,t.starttop
,t.startleft
,t.length
,t.decimals
,t.alignment
( select tt.alignment from temptable tt where tt.rownum = t.rownum+1 ) nextalign
from temptable t
Might work for you.