Forum Discussion
RyanPB
7 years agoRegular Visitor
Need help in creating SQL query which gives same result as created using calculated table
I have created a calculated table using the "New Table" option from Modeling menu on the Ribbon in power BI. NewCalTable = UNION(SELECTCOLUMNS(SalesInfo,"Type", "Sold", "Product", SalesInfo[Produ...
- 7 years ago
Hi RyanPB,
The SQL statement could be like below. I would suggest you use DAX instead.
SELECT 'Daily Sales' AS Type,
product AS Product,
CONVERT(VARCHAR, solddate, 23) AS SaleDate
FROM salesinfo
UNION
SELECT 'Weekly Sales' AS Type,
product AS Product,
CONVERT(VARCHAR, Dateadd(day, - Datepart(weekday, solddate) + 1, solddate
), 23)
+ '-'
+ CONVERT(VARCHAR, Dateadd(day, 7 - Datepart(weekday, solddate), solddate
), 23)
AS SaleDate
FROM salesinfo;Best Regards,
Dale
v-jiascu-msft
7 years agoMicrosoft Employee