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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
RonSwanson
Frequent Visitor

SQL to DAX Conversion

Hi Experts,

 

Looking to translate the below into DAX, but I have little experience.  Any ideas? Thanks in advance.

 

CASE WHEN (25000 <
CASE WHEN [ReSignedMembers] is missing THEN 0 ELSE [ReSignedMembers] END +
CASE WHEN  [ConversionMembers] is missing THEN 0 ELSE [ConversionMembers] END +
CASE WHEN  [NewMembers] is missing THEN 0 ELSE [NewMembers] END +
CASE WHEN  [MaintenanceMembers] is missing THEN 0 ELSE CASE WHEN [MaintenanceMembers] < 0 THEN 0 ELSE [MaintenanceMembers] END END)
THEN (25000) ELSE (
CASE WHEN [ReSignedMembers] is missing THEN 0 ELSE [ReSignedMembers] END +
CASE WHEN  [ConversionMembers] is missing THEN 0 ELSE [ConversionMembers] END +
CASE WHEN  [NewMembers] is missing THEN 0 ELSE [NewMembers] END +
CASE WHEN  [MaintenanceMembers] is missing THEN 0 ELSE CASE WHEN [MaintenanceMembers] < 0 THEN 0 ELSE [MaintenanceMembers] END END
) END
1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @RonSwanson ,

The whole dax code may like this:

A =
IF (
    25000
        < IF ( ISBLANK ( [ReSignedMembers] ), 0, [ReSignedMembers] )
            + IF ( ISBLANK ( [ConversionMembers] ), 0, [ConversionMembers] )
            + IF ( ISBLANK ( [NewMembers] ), 0, [NewMembers] )
            + IF (
                ISBLANK ( [MaintenanceMembers] ),
                0,
                IF ( [MaintenanceMembers] < 0, 0, [MaintenanceMembers] )
            ),
    25000,
    IF ( ISBLANK ( [ReSignedMembers] ), 0, [ReSignedMembers] )
        + IF ( ISBLANK ( [ConversionMembers] ), 0, [ConversionMembers] )
        + IF ( ISBLANK ( [NewMembers] ), 0, [NewMembers] )
        + IF (
            ISBLANK ( [MaintenanceMembers] ),
            0,
            IF ( [MaintenanceMembers] < 0, 0, [MaintenanceMembers] )
        )
)

 

Best Regards,
Yingjie Li

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

View solution in original post

5 REPLIES 5
v-yingjl
Community Support
Community Support

Hi @RonSwanson ,

The whole dax code may like this:

A =
IF (
    25000
        < IF ( ISBLANK ( [ReSignedMembers] ), 0, [ReSignedMembers] )
            + IF ( ISBLANK ( [ConversionMembers] ), 0, [ConversionMembers] )
            + IF ( ISBLANK ( [NewMembers] ), 0, [NewMembers] )
            + IF (
                ISBLANK ( [MaintenanceMembers] ),
                0,
                IF ( [MaintenanceMembers] < 0, 0, [MaintenanceMembers] )
            ),
    25000,
    IF ( ISBLANK ( [ReSignedMembers] ), 0, [ReSignedMembers] )
        + IF ( ISBLANK ( [ConversionMembers] ), 0, [ConversionMembers] )
        + IF ( ISBLANK ( [NewMembers] ), 0, [NewMembers] )
        + IF (
            ISBLANK ( [MaintenanceMembers] ),
            0,
            IF ( [MaintenanceMembers] < 0, 0, [MaintenanceMembers] )
        )
)

 

Best Regards,
Yingjie Li

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

amitchandak
Super User
Super User

@RonSwanson , it would be a combination of switch true and if. Setup a small example

 

Switch (true(),
25000 < if(isblank( [ReSignedMembers] ) , 0 , [ReSignedMembers] ) +
if(isblank( [ConversionMembers] ) , 0 , [ConversionMembers] ) +


/// Try to do rest
CASE WHEN [NewMembers] is missing THEN 0 ELSE [NewMembers] END +
CASE WHEN [MaintenanceMembers] is missing THEN 0 ELSE CASE WHEN [MaintenanceMembers] < 0 THEN 0 ELSE [MaintenanceMembers] END END)
THEN (25000) ELSE (
CASE WHEN [ReSignedMembers] is missing THEN 0 ELSE [ReSignedMembers] END +
CASE WHEN [ConversionMembers] is missing THEN 0 ELSE [ConversionMembers] END +
CASE WHEN [NewMembers] is missing THEN 0 ELSE [NewMembers] END +
CASE WHEN [MaintenanceMembers] is missing THEN 0 ELSE CASE WHEN [MaintenanceMembers] < 0 THEN 0 ELSE [MaintenanceMembers] END END
)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Greg_Deckler
Super User
Super User

@RonSwanson Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
harshnathani
Community Champion
Community Champion

Hi @RonSwanson ,

 

Try using SWITCH () statement

 

https://www.youtube.com/watch?v=-ykkaAtlCMc&vl=en

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

vanessafvg
Super User
Super User

you need the switch() statement

https://powerpivotpro.com/2015/03/the-diabolical-genius-of-switch-true/




If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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