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

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

Reply
Anonymous
Not applicable

get column based on multiple if conditions

 

Hello All,

Iam working on migration project and have requirment like this:

In a table, i want to display different columns based on different conditions in single dax. For example, if condition-A becomes true , i need to display column1, if cond-2 is true, i want to display column2, if cond-3, column3.....This is working for pie chart visual, but not for table.

Pls let me know solution for this.

For refrence purpose, iam attaching the qlik expression here, which need to be converted to dax.

=if(GetSelectedCount(Direct) > 0 and GetSelectedCount(VP_Director) = 0 and GetSelectedCount(Director_Manager) = 0 and GetSelectedCount(Manager) = 0 , VP_Director, if( (GetSelectedCount(Direct) > 0 and GetSelectedCount(VP_Director) > 0 and GetSelectedCount(Director_Manager) = 0 and GetSelectedCount(Manager) = 0) or (GetSelectedCount(VP_Director) > 0 and GetSelectedCount(Direct) = 0 and GetSelectedCount(Director_Manager) = 0 and GetSelectedCount(Manager) = 0) , Director_Manager, if( (GetSelectedCount(Direct) > 0 and GetSelectedCount(VP_Director) > 0 and GetSelectedCount(Director_Manager) > 0 and GetSelectedCount(Manager) = 0) or (GetSelectedCount(VP_Director) = 0 and GetSelectedCount(Direct) > 0 and GetSelectedCount(Director_Manager) > 0 and GetSelectedCount(Manager) = 0) or (GetSelectedCount(VP_Director) > 0 and GetSelectedCount(Direct) = 0 and GetSelectedCount(Director_Manager) > 0 and GetSelectedCount(Manager) = 0) , Manager, if( (GetSelectedCount(Direct) > 0 and GetSelectedCount(VP_Director) > 0 and GetSelectedCount(Director_Manager) > 0 and GetSelectedCount(Manager) > 0) or (GetSelectedCount(VP_Director) = 0 and GetSelectedCount(Direct) > 0 and GetSelectedCount(Director_Manager) > 0 and GetSelectedCount(Manager) > 0) or (GetSelectedCount(VP_Director) > 0 and GetSelectedCount(Direct) = 0 and GetSelectedCount(Director_Manager) > 0 and GetSelectedCount(Manager) > 0) or (GetSelectedCount(VP_Director) = 0 and GetSelectedCount(Direct) = 0 and GetSelectedCount(Director_Manager) = 0 and GetSelectedCount(Manager) > 0) , SUBAREA_OWNER ))))

[4:41 PM] Vamshi Krishna Nomula
okay
5 REPLIES 5
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You could try the following DAX:

Column =
VAR a =
    COUNT ( 'Table'[Direct] )
VAR b =
    COUNT ( 'Table'[VP_Director] )
VAR c =
    COUNT ( 'Table'[Director_Manager] )
VAR d =
    COUNT ( 'Table'[Manager] )
RETURN
    IF (
        d > 0,
        "SUBAREA_OWNER",
        IF (
            c > 0,
            "Manager",
            IF ( b > 0, "Director_Manager", IF ( a > 0, "VP_Director" ) )
        )
    )

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
Anonymous
Not applicable

@v-eachen-msft Thanks for the help. but this solution doesn't work for requirment

MFelix
Super User
Super User

Hi @Anonymous ,

 

Try the following code (may need adjustments):

 

ttt =
SWITCH (
    TRUE (),
    COUNT ( Table[Direct] ) > 0
        && COUNT ( Table[VP_Director] ) = 0
        && COUNT ( Table[Director_Manager] ) = 0
        && COUNT ( Table[Manager] ) = 0, "VP_Director",
    (
        COUNT ( Table[Direct] ) > 0
            && COUNT ( Table[DirectVP_Director] ) > 0
            && COUNT ( Table[Director_Manager] ) = 0
            && COUNT ( Table[Manager] ) = 0
    )
        || (
            COUNT ( Table[VP_Director] ) > 0
                && COUNT ( Table[Direct] ) = 0
                && COUNT ( Table[Director_Manager] ) = 0
                && COUNT ( Table[Manager] ) = 0
        ), "Director_Manager",
    (
        COUNT ( Table[Direct] ) > 0
            && COUNT ( Table[VP_Director] ) > 0
            && COUNT ( Table[Director_Manager] ) > 0
            && COUNT ( Table[Manager] ) = 0
    )
        || (
            COUNT ( Table[VP_Director] ) = 0
                && COUNT ( Table[Direct] ) > 0
                && COUNT ( Table[Director_Manager] ) > 0
                && COUNT ( Table[Manager] ) = 0
        )
        || (
            COUNT ( Table[VP_Director] ) > 0
                && COUNT ( Table[Direct] ) = 0
                && COUNT ( Table[Director_Manager] ) > 0
                && COUNT ( Table[Manager] ) = 0
        ), "Manager",
    (
        COUNT ( Table[Direct] ) > 0
            && COUNT ( Table[VP_Director] ) > 0
            && COUNT ( Table[Director_Manager] ) > 0
            && COUNT ( Table[Manager] ) > 0
    )
        || (
            COUNT ( Table[VP_Director] ) = 0
                && COUNT ( Table[Direct] ) > 0
                && COUNT ( Table[Director_Manager] ) > 0
                && COUNT ( Table[Manager] ) > 0
        )
        || (
            COUNT ( Table[VP_Director] ) > 0
                && COUNT ( Table[Direct] ) = 0
                && COUNT ( Table[Director_Manager] ) > 0
                && COUNT ( Table[Manager] ) > 0
        )
        || (
            COUNT ( Table[VP_Director] ) = 0
                && COUNT ( Table[Direct] ) = 0
                && COUNT ( Table[Director_Manager] ) = 0
                && COUNT ( Table[Manager] ) > 0
        ), SUBAREA_OWNER
)

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

@MFelix This doesn't work

Hi @Anonymous ,

 

Can you please share a small smaple of your datafile?

 

Are this columns on your model? And what type of data do they have?

Direct, VP_Director, Director_Manager, Manager


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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