SQL Script in DAX ( Many different Joins ) - postgresql

I have a problem in Power BI with DAX, i want to do SQL joins in Dax , i made my data modelling with my tree tables
Table 1
enter image description here
table 2
enter image description here
table 3
enter image description here
I want to do with DAX this table joining in this SQL query
enter image description here
I want to create a table with the joining bloc
Can you help me ?
Kind Regards ;
I try to do it on power query but i have some speed issue

In power bi, you would address this by creating relationships in the model:
https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-create-and-manage-relationships
Please note that all joins are equivalent to outer joins in SQL. Some of what is in your ssample query is not valid SQL syntax - you can't have duplicate table names, "join" is repeated. However, if you wish to filter a table like T3.U2 = 'NW', you can simply add that as a WHERE clause in the query to import the data into the model or filter out the rows you want with PowerQuery (using the edit queries dialogue in power bi).

Related

How do I import data from SQL Server Views?

How do I Import data into SSAS from SQL server Views? It only shows me Tables. I have views already customized to provide the data the way it should be.
You can expand the "Advanced Options" and use SQL.
SELECT * FROM MY_VIEW_NAME
Note that any filters that reduce the size of the data should be done in your SQL, as Power Query does not do any query folding after an SQL statement. That means if your SQL is like the one above, you will have to wait until every row is sent to Power BI, and then any other filters in your Power Query would be done by Power BI.
If you are not familiar with SQL, set filters with a WHERE clause:
SELECT * FROM MY_VIEW_NAME
WHERE COLUMN_1 = 'US'
AND COLUMN_2 > 0

Difference in partitioned and non-partitioned table in terms of vertical join in q kdb

I have two non-partitioned tables:
q)s:([] date:(2019.07.01;2019.07.01;2019.07.02;2019.07.01;2019.07.05); co:`a`b`f`b`c)
q)t:([] date:(2019.07.01;2019.07.01;2019.07.02;2019.07.01;2019.07.07); co:`a`b`e`b`d)
In above table when I run below query it works perfectly fine.
q)select distinct co from s,t where date within 2019.07.01 2019.07.02
co
--
a
b
f
e
I have tables with same name which are partitioned by date, when I try to run same query on partitioned tables I get below error:
ERROR: 'par
(trying to update a physically partitioned table)
Why do we get above error in partitioned tables?
What is the optimized approach to get similar output as we got in non-partitioned tables?
One solution to for 2 which I feel as brute-force is:
select distinct co from((select distinct co from s where date within 2019.07.01 2019.07.02),select distinct co from t where date within 2019.07.01 2019.07.02)
I'm assuming you are only including the date name in the source tables to assist in queries. A date partitioned table will generate the virtual date column from the hdb structure, you shouldn't include it in the actual table being written to.
Why do we get above error in partitioned tables?
There is no way to avoid having to access the data of a partitioned table except through an initial a select statement.. In this case you are directly trying to perform a , operation to the s and t tables
What is the optimized approach to get similar output as we got in non-partitioned tables?
In general, there may be a trade-off between the table size and the nature and frequency of the operations, sometimes it may be worth bringing the table into memory for frequent joins, or creating a top-level flat table with the relevant subset of data.
If this is just a generalized test case for larger operations then something along the following would be ideal
distinct raze {select distinct co from x where date within 2019.07.01 2019.07.02} each `s`t
This performance is not very different from your own query however, it's just a bit more succinct.

Pivot column in SSRS

I have report where I am using that stored procedure to create a report using SSRS. The report currently show data like below (it has more additional columns) :
What I want is at the backend (stored procedure level or in SSRS) want the filter the data for product_type A only, but I want to show the amount associated with the product type F in a new column as below:
Can anyone help to achieve this please?
A simple LEFT JOIN with the same table will do the work
SELECT t1.INVOICE_NO,t1.PRODUCT_TYPE,t1.AMOUNT,t2.AMOUNT AS FEE_AMOUNT
FROM tbl t1
LEFT JOIN tbl t2 ON t1.INVOICE_NO=t2.INVOICE_NO AND t2.PRODUCT_TYPE='F'
WHERE t1.PRODUCT_TYPE='A'
you can also use matrix to achieve the same on ssrs side. In this case your trade off is none i.e. doing pivot on sql side and then rendering the data in ssrs table VS leaving data as is in sql and using matrix to pivot the data.

Join calculation in Tableau

In my viz I have 2 tables, Orders and Returns
I have created a column called Order Id using Custom Split for Returns Table.
Now I'm trying to join the Orders and returns table using the Order Id but Order Id doesn't show up in the join drop down. how do i go about from here to create a custom join calculation option.
Image attachment :
When you split a column, it shows up as a "Calculated field". If you want to join on something which is not in the primary data source then you might as well create it first and then load the data in Tableau.
You must have noticed though that the split columns show up when you move to a worksheet. In your case, you can simply join on the "Order ID" which is present in both data sets (Superstore data).
Hope this helps.

Need sql query to display row numbers in table

I need sql query to display row numbers in table. I am working in Mainframes and we use SQL queries to connect to oracle tables . I need a query to display row numbers in a table , table doesnt have a column for row numbers . In Mainframes we can input sql queries alone . Any help will be greatly appreciated!!
You can use ROWNUM Pseudocolumn.
Example
SELECT ROWNUM,a.* FROM employees a;