web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Left Join

(0) ShareShare
ReportReport
Posted on by

Hi 

I am using Microsoft Dynamics NAV 2013 and SQL server 2014

I have created  a new table which contains data from the Excise Rate, Location , Item and Item Unit of Measure tables in order to calculate Transfer Excise. Transfer Excise is Tax that we pay when our wine gets transported from one Warehouse to another. I did a Left Join to the Value Entry table which contains all item related transactions as I need the Invoice Quantity column to calculate Transfer Excise. This is how I calculate Transfer Excise: (Invoiced Quantity / Litre Conversion Factor * Unit Rate) = Transfer Excise. With this approach I did get the desired result , see the SQL script to get the Transfer Excise

SELECT DISTINCT b.[Entry No_] ,
                a.[Starting Date],
                b.[Posting Date], 
				b.[Item No_],  
				b.[Invoiced Quantity],  
				b.[Sales Amount (Actual)],
				a.[Litre Conversion Factor], 
				a.[Unit Rate] , 
	            b.[Location Code],  
				a.[Excise Location], 
				a.[Excise Type Code], 
				a.[Unit Of Measure Code]				
FROM [Spier Live$Value Entry] b 
LEFT JOIN [Transfer Excise Tbl] a 
ON a.[No_] = b.[Item No_]
AND b.[Location Code] = a.[Location Code]
AND DateDiff(y,b.[Posting Date],a.[Starting Date]) > -365 
AND DateDiff(y,b.[Posting Date],a.[Starting Date]) < 0    
WHERE b.[Posting Date] > '2013-02-26'                   
AND b.[Gen_ Bus_ Posting Group] IN ('LOCA','EXSA')
AND b.[Invoiced Quantity] <>0                             

GROUP BY  b.[Entry No_] ,a.[Starting Date], b.[Posting Date], b.[Item No_],  b.[Invoiced Quantity],  
		  b.[Sales Amount (Actual)], a.[Litre Conversion Factor], a.[Unit Rate] , 
	      b.[Location Code], a.[Excise Location], a.[Excise Type Code], a.[Unit Of Measure Code]




			


With all this done , the sales amount (Actual) value changes which should not be the case. Someone told me that it might be the Left Join causing the Sales Amount to change. I cannot change the script because then the Transfer Excise Value will be incorrect or is there another or better way of writing this query so that the sales amount (Actual) and Transfer Excise will be the same and correct value

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Suresh Kulla Profile Picture
    50,235 Super User 2025 Season 2 on at
    RE: Left Join

    Hello,

    Can you provide an example of the result which is incorrect, when you mentioned the sales amount actual value changes what do you mean and how are you verifying the result ?

  • Community Member Profile Picture
    on at
    RE: Left Join

    As per my script I removed all the columns accept Sales Amount(Actual) this is to show you that the value of the Sales Amount (Actual) changes. Without the left join script to the other table , my Sales Amount (Actual) is correct , however I need to join to that table to get my Transfer Excise Value so that I can continue to do other calculations which need the Transfer Excise value. my  Sales Amount (Actual) should be 32, 145, 105.66 as per my second screenshot. The second screenshot is my OLAP Cube report so I trying to work with my relational data source and compare the values I get in Navision against the Olap cube , because the Olap cube gets its information from Navision every evening.  Is there a better way of writing the script so that it does not affect the other values , coming from the Value Entry Table
    Navision-sales-amount-actual.JPG

  • Suggested answer
    Suresh Kulla Profile Picture
    50,235 Super User 2025 Season 2 on at
    RE: Left Join

    Jason,

    I don't see your second screenshot can you please attach it again.

  • Community Member Profile Picture
    on at
    RE: Left Join

    Hi Suresh attached please find my second screenshot as requested

    Sales-Amount-Actual.JPG

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
Saurav.Dhyani Profile Picture

Saurav.Dhyani 2 Super User 2025 Season 2

#1
Alexander Ermakov Profile Picture

Alexander Ermakov 2

#3
RK-25090803-0 Profile Picture

RK-25090803-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans