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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

DAX to SQL code help

HI Experts,

Could anyone please translate below DAX into SQL please

 

1. AIMS = IF(LEN(A.L)>=10 and IFERROR(VALUE(RIGHT(Asset[A_L],1)),FALSE()),"AIMS","ANIMS")

2. AIMS = IF(Asset[AGAL] IN DISTINCT('H S'[AG]) && A[AIMS]="AIMS","I M S","N i M S")

3. AGAL = A[A_L] & "_" & A[AG]

4. AIMLS = IF(Asset[AGAL IN DISTINCT('H S'[AG]) && Asset[AIMxS]="AIMXS","I M S","N in M S")

 

thanks 

1 ACCEPTED SOLUTION
technolog
Super User
Super User

Hi!

The DAX expressions you provided can be translated into SQL as follows:

For the DAX expression:
AIMS = IF(LEN(A.L)>=10 and IFERROR(VALUE(RIGHT(Asset[A_L],1)),FALSE()),"AIMS","ANIMS")
The SQL translation would be:

CASE
WHEN LEN(A.L) >= 10 AND ISNUMERIC(RIGHT(Asset.A_L, 1)) = 1 THEN 'AIMS'
ELSE 'ANIMS'
END AS AIMS
For the DAX expression:
AIMS = IF(Asset[AGAL] IN DISTINCT('H S'[AG]) && A[AIMS]="AIMS","I M S","N i M S")
The SQL translation would be:

CASE
WHEN Asset.AGAL IN (SELECT DISTINCT AG FROM H_S) AND A.AIMS = 'AIMS' THEN 'I M S'
ELSE 'N i M S'
END AS AIMS
For the DAX expression:
AGAL = A[A_L] & "_" & A[AG]
The SQL translation would be:

CONCAT(A.A_L, '_', A.AG) AS AGAL
For the DAX expression:
AIMLS = IF(Asset[AGAL IN DISTINCT('H S'[AG]) && Asset[AIMxS]="AIMXS","I M S","N in M S")
The SQL translation would be:

CASE
WHEN Asset.AGAL IN (SELECT DISTINCT AG FROM H_S) AND Asset.AIMxS = 'AIMXS' THEN 'I M S'
ELSE 'N in M S'
END AS AIMLS

View solution in original post

1 REPLY 1
technolog
Super User
Super User

Hi!

The DAX expressions you provided can be translated into SQL as follows:

For the DAX expression:
AIMS = IF(LEN(A.L)>=10 and IFERROR(VALUE(RIGHT(Asset[A_L],1)),FALSE()),"AIMS","ANIMS")
The SQL translation would be:

CASE
WHEN LEN(A.L) >= 10 AND ISNUMERIC(RIGHT(Asset.A_L, 1)) = 1 THEN 'AIMS'
ELSE 'ANIMS'
END AS AIMS
For the DAX expression:
AIMS = IF(Asset[AGAL] IN DISTINCT('H S'[AG]) && A[AIMS]="AIMS","I M S","N i M S")
The SQL translation would be:

CASE
WHEN Asset.AGAL IN (SELECT DISTINCT AG FROM H_S) AND A.AIMS = 'AIMS' THEN 'I M S'
ELSE 'N i M S'
END AS AIMS
For the DAX expression:
AGAL = A[A_L] & "_" & A[AG]
The SQL translation would be:

CONCAT(A.A_L, '_', A.AG) AS AGAL
For the DAX expression:
AIMLS = IF(Asset[AGAL IN DISTINCT('H S'[AG]) && Asset[AIMxS]="AIMXS","I M S","N in M S")
The SQL translation would be:

CASE
WHEN Asset.AGAL IN (SELECT DISTINCT AG FROM H_S) AND Asset.AIMxS = 'AIMXS' THEN 'I M S'
ELSE 'N in M S'
END AS AIMLS

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.