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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
integrateErck
New Member

Converting SQl logic to DAX

HI All,

 

Working on getting transfering this expression as a measue in a tabular model.

 

The SQL is accurate but running into issues on the measure.

 

SQL:

CASE
WHEN Sale_Type = 'Upsell'
AND Product IN('SaaS')
AND NULLIF( DATEDIFF( DD,Start_Date], ISNULL( Renewal_date],end_date ) ) + 1,0 ) > 364
THEN ARR
ELSE TotalPrice
END AS 'TotalContractualValue'

 

 

DAX Attempt: 
SWITCH( Sale_Type = "Upsell" && Product IN ("SaaS")
&& DateDiff ( StartDate], IF( ISBLANK( RenewalDate), EndDate, RenewalDate, DAY ) + 1 > 364, ARR
TotalPrice ) )))

 

 

Unfortunately, no matter how I word this or break it down, I end up with the same warning message and error:

Severity Code Description Project File Line Suppression State
Operator or expression '( )' is not supported in this context. 

 

 

Any thoughts?

 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @integrateErck 

Thanks for reaching out to us.

>>

CASE
WHEN Sale_Type = 'Upsell'
AND Product IN('SaaS')
AND NULLIF( DATEDIFF( DD,Start_Date], ISNULL( Renewal_date],end_date ) ) + 1,0 ) > 364
THEN ARR
ELSE TotalPrice
END AS 'TotalContractualValue'

 

measure code:

Measure = 
var _datediff=DATEDIFF(MIN('Table'[Start_Date]),IF(ISBLANK(MIN('Table'[Renewal_date])),MIN('Table'[end_date]),MIN('Table'[Renewal_date])),DAY)+1
var _istrue= _datediff>364
return
IF(MIN('Table'[Sale_Type])="Upsell" && MIN('Table'[Product]) in {"SaaS"} && _istrue, [ARR],[TotalPrice] )

vxiaotang_1-1662431300131.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-xiaotang
Community Support
Community Support

Hi @integrateErck 

Thanks for reaching out to us.

>>

CASE
WHEN Sale_Type = 'Upsell'
AND Product IN('SaaS')
AND NULLIF( DATEDIFF( DD,Start_Date], ISNULL( Renewal_date],end_date ) ) + 1,0 ) > 364
THEN ARR
ELSE TotalPrice
END AS 'TotalContractualValue'

 

measure code:

Measure = 
var _datediff=DATEDIFF(MIN('Table'[Start_Date]),IF(ISBLANK(MIN('Table'[Renewal_date])),MIN('Table'[end_date]),MIN('Table'[Renewal_date])),DAY)+1
var _istrue= _datediff>364
return
IF(MIN('Table'[Sale_Type])="Upsell" && MIN('Table'[Product]) in {"SaaS"} && _istrue, [ARR],[TotalPrice] )

vxiaotang_1-1662431300131.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

Jameswalter
New Member

First, click on the DAX query button in SSMS.
This will launch the screen that lets you select and connect to the SSAS Server with the Tabular Database you install above.
Make sure you select the database you want to query.
Proceed to write and execute your DAX queries.

Regards,
J Wick

integrateErck
New Member

Thank you @amitchandak 
Unfortunately, this needs to be a measure

amitchandak
Super User
Super User

@integrateErck , Try this as new column Not measure

 

SWITCH( True() ,
[Sale_Type] = "Upsell" && [Product] IN ("SaaS")
&& DateDiff ( StartDate], IF( ISBLANK( RenewalDate), EndDate, RenewalDate), DAY ) + 1 > 364, [ARR],
[TotalPrice] )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.