Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
David_Aideti
Partner - Contributor
Partner - Contributor

Dividing two columns

Hello, 

In the next code I want to obtain the Price per unit but when I apply the division to these two field the error from below occurs. 

[Data]:
LOAD
[ID_Factura],
[Date],
[Market],
[Product],
Sum([Units]) AS [Units],
Sum([Sales]) AS [Sales],
[Sales]/[Units] AS [PricePerUnit],
APPLYMAP( '__countryCodeIsoThree2Polygon', APPLYMAP( '__countryName2IsoThree', LOWER([Market])), '-') AS [Data.Market_GeoInfo]
FROM [lib://Downloads/Data Workshop.xlsx]
(ooxml, embedded labels, table is Data)
WHERE [Date] >= Date#('01/2018') AND NOT IsNull([ID_Factura])
GROUP BY [Date], [Market],[Product],[ID_Factura],[PricePerUnit];

David_Aideti_0-1666684271387.png

 

Labels (2)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

changes highligh6ted below

[Data]:
LOAD
[ID_Factura],
[Date],
[Market],
[Product],
Sum([Units]) AS [Units],
Sum([Sales]) AS [Sales],
Sum([Units]) /Sum([Sales]) AS [PricePerUnit],
APPLYMAP( '__countryCodeIsoThree2Polygon', APPLYMAP( '__countryName2IsoThree', LOWER([Market])), '-') AS [Data.Market_GeoInfo]
FROM [lib://Downloads/Data Workshop.xlsx]
(ooxml, embedded labels, table is Data)
WHERE [Date] >= Date#('01/2018') AND NOT IsNull([ID_Factura])
GROUP BY [Date], [Market],[Product],[ID_Factura];

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

4 Replies
vinieme12
Champion III
Champion III

remove [PricePerUnit] from Group By,  this field will exist after the  load  statement has executed

 

[Data]:
LOAD
[ID_Factura],
[Date],
[Market],
[Product],
Sum([Units]) AS [Units],
Sum([Sales]) AS [Sales],
[Sales]/[Units] AS [PricePerUnit],
APPLYMAP( '__countryCodeIsoThree2Polygon', APPLYMAP( '__countryName2IsoThree', LOWER([Market])), '-') AS [Data.Market_GeoInfo]
FROM [lib://Downloads/Data Workshop.xlsx]
(ooxml, embedded labels, table is Data)
WHERE [Date] >= Date#('01/2018') AND NOT IsNull([ID_Factura])
GROUP BY [Date], [Market],[Product],[ID_Factura];

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
David_Aideti
Partner - Contributor
Partner - Contributor
Author

Hi, thanks for your response. In these case I obtain the next error. 

David_Aideti_0-1666686268593.png

 

vinieme12
Champion III
Champion III

changes highligh6ted below

[Data]:
LOAD
[ID_Factura],
[Date],
[Market],
[Product],
Sum([Units]) AS [Units],
Sum([Sales]) AS [Sales],
Sum([Units]) /Sum([Sales]) AS [PricePerUnit],
APPLYMAP( '__countryCodeIsoThree2Polygon', APPLYMAP( '__countryName2IsoThree', LOWER([Market])), '-') AS [Data.Market_GeoInfo]
FROM [lib://Downloads/Data Workshop.xlsx]
(ooxml, embedded labels, table is Data)
WHERE [Date] >= Date#('01/2018') AND NOT IsNull([ID_Factura])
GROUP BY [Date], [Market],[Product],[ID_Factura];

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
David_Aideti
Partner - Contributor
Partner - Contributor
Author

Now it works! Thanks