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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

SQL to DAX Converstion - Create complex aggregation measure using conditions

I'm new to PowerBi/DAX and have a burning need to create ~10-15 complex aggregate measures from a related table (Deal Investment) that will be aggregated and stored on another table (Deal).  The differences are real, and any help is sincerely appreciated.  I am assuming that I will need to use Calculate SUMX and related function syntax, but asking for some newbie guidance from the community.

Here is a sample SQL query that I need to replicate in DAX:

  • SQL query Table reference:  dit = [Deal Investment Type] ; di = [Deal Investment]; d = [Deal]
  • Calculated Column on [Deal Investment] (inserted to SQL below) = [New Money Flag] 
SQL Syntax for "Total Sr. Secured Debt Amount" calc:
SUM(
    CASE WHEN di.new_typeidname IN ('Delayed Draw - Senior Debt', 'RCF') AND di.[New Money flag] = 1 THEN ISNULL(di.new_drawnamountglobal,0)
    WHEN dit.new_securitytype = '100000004' and di.new_typeidname NOT IN ('Delayed Draw - Senior Debt', 'RCF','Senior Subordinated Debt') AND di.[new Money flag] = 1 THEN
    CASE WHEN di.new_ivpinvestmenttypename IN ('Cash') THEN -1 * ABS(ISNULL(di.new_amount, 0))
            ELSE ISNULL(di.new_amount, 0)
            END
        END
       ) / 1000000 as total_srsecdebt_amt
3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

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



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks Greg, point taken!  Since my question is really a question of syntax conversion from SQL to DAX for nested Case/When statements, I assumed that providing the relevant table references and SQL logic would suffice.  That being said, I will provide a dataset and walk through the calculation logic in plain English.   Thanks for taking the time to respond!  

In between refer:https://www.youtube.com/watch?v=UsAJPIANAb8

https://community.powerbi.com/t5/Desktop/Help-with-SWITCH-TRUE-with-multiple-items-to-evaluate/td-p/...

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
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.