Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
J_4923
Frequent Visitor

SQL to DAX

Hi,

 

I would like to create a calculated table but don't know how to translate below to DAX?

 

/****** Script for SelectTopNRows command from SSMS  ******/
select distinct * from (

SELECT distinct originCountry as country, originArea as area, OriginRegion as region,seaair as product, customerName as customer
  FROM tmp where ETDYear = 2017

  union all

 
SELECT distinct DestinationCountry as country, DestinationArea as area, DestinationRegion as region,seaair as product, customerName as customer
  FROM tmp where ETDYear = 2017

  union all

  SELECT distinct FreightPayerCountry as country, FreightPayerArea as area, FreightPayerRegion as region,seaair as product, customerName as customer
  FROM tmp where ETDYear = 2017 
  
    union all

  SELECT distinct CRMOwnerCountry as country, CRMOwnerArea as area, CRMOwnerRegion as region, customerName as customer
  FROM tmp where ETD = '2017-03-12' and BLNumber in ('0001748TPA','AAR0029009')

 
  ) as GEOCustomer where area != 'AGENT' order by customer

1 ACCEPTED SOLUTION
v-caliao-msft
Microsoft Employee
Microsoft Employee

@J_4923,

 

You could use this query in Power BI desktop directly.
Capture.PNG

 

Besides, there are big difference between T-SQL query and DAX query. You'd better to learn DAX basics before you can convert T-SQL to DAX, here are some useful links for you reference.
https://support.office.com/en-us/article/QuickStart-Learn-DAX-Basics-in-30-Minutes-51744643-c2a5-436...
https://www.sqlbi.com/topics/from-sql-to-dax/

 

Regards,

Charlie Liao
 

View solution in original post

2 REPLIES 2
v-caliao-msft
Microsoft Employee
Microsoft Employee

@J_4923,

 

You could use this query in Power BI desktop directly.
Capture.PNG

 

Besides, there are big difference between T-SQL query and DAX query. You'd better to learn DAX basics before you can convert T-SQL to DAX, here are some useful links for you reference.
https://support.office.com/en-us/article/QuickStart-Learn-DAX-Basics-in-30-Minutes-51744643-c2a5-436...
https://www.sqlbi.com/topics/from-sql-to-dax/

 

Regards,

Charlie Liao
 

jmalone
Resolver III
Resolver III

Is there a reason you need this table as a calculated table using DAX?

 

It may be easier to use the Query Editor to import your tables (origin, destination, FreightPayer, and CRMOwner) as separate queries, rename the headers, then append into a single table.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors