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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
rma2219
Regular Visitor

Convert DAX to M Code

Hello! Need help on the following scenario. So we are already set with our measure and working as expected Here it is:
Solution=

VAR countSolution=

    CALCULATE ( COUNTA ( 'RiskColumn'[Solution] ) )

VAR countLagging =

    CALCULATE (

        COUNTA ( 'RiskColumn'[Solution] ),

        FILTER (

            'RiskColumn',

            'RiskColumn'[Category] = "Lagging"

        )

    )

VAR countNotDelay =

    CALCULATE (

        COUNTA ( 'RiskColumn'[Solution] ),

        FILTER (

            'RiskColumn',

            ' RiskColumn'[Category] = "Not Delay"

        )

    )

RETURN

    SWITCH (

        TRUE (),

        countDelay = countSolution

            && countLagging <= 0

            || countLagging <= 0

            && countNotDelay > 0, "Excellent",

        ( countLagging = 1

            || countLagging = 2 ), "Satisfactory",

        ( countLagging >= 3 ), "For Improvement"

    )

Unfortunately, we need to have this converted to M code, so we just want to instead a column in the backend where it will contain the Level Column containing "Excellent", "Satisfactory", and "For Improvement"

I have this sample table similar to what we have in the backend but we are stuck at how the m code should look like so that each Solution is only mapped to only one level (excellent, satisfactory, etc). Or may be there are other ways to do this? 

SolutionRisk CategoryCountQuality Category
XDelay2Lagging
XNot delay3On time
YDelay1Lagging
YNot delay1On time
ZDelay0On time
ZNot delay3On time


Please let us know. Thanks!

1 REPLY 1
lbendlin
Super User
Super User

so that each Solution is only mapped to only one level

You need to describe the aggregation rules for your scenario where you have multiple rows per Solution,

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

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.