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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
arashaga
Helper I
Helper I

My Columns do not show up in the DAX editor

I am trying to do a little switch statement such as

 

Switch([Institution] , "A", "1","B",2 ....)

 

but after switch statement DAX does not recognize my columns where it usually pop up with intelisene and even when I type it it cannot recognize the columns. However it only recognizes the measure that I created previously. I would like to know what I am doing wrong here. Thanks

1 ACCEPTED SOLUTION

Hi @arashaga,

 

You want to make such a Switch statement via a measure, right? Is [institution] a field name?

 

Please try this

Measure =
SWITCH (
    SELECTEDVALUE ( Table1[institution] ),
    "A", CALCULATE (
        COUNT ( Table1[Column] ),
        FILTER ( ALL ( Table1 ), Table1[Column] = "G" )
    ),
    "B", CALCULATE (
        COUNT ( Table1[Column] ),
        FILTER ( ALL ( Table1 ), Table1[Column] = "K" )
    )
)

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

6 REPLIES 6
Anonymous
Not applicable

In your case, you are trying to create a measure with SWITCH statement and hence DAX suggests only measures.

 

If you create this as calculated column, you will see the option of columns as well.

 

Thanks
Raj

How do you use switch with calculate?

Anonymous
Not applicable

If you could post some sample data and expeced output, would be easy to suggest .

 

If needed , you can use the IF or SWITCH in the filter with logic.

Thanks

Raj

I would like to do the following calculation. I am trying to compare one institution with it's peer institution.

For instance compare A with G and B with K. Also,

I will most likely have some other filters in the page so I would like to igonre some of them as well.

 

if institution = "A"
then ignore all the filters and give me the total attendance for institution G
if institution = "B"
then ignore all the filters and give me the total attendance for institution K

 

I hope this would help to describe what I need to do.

Hi @arashaga,

 

You want to make such a Switch statement via a measure, right? Is [institution] a field name?

 

Please try this

Measure =
SWITCH (
    SELECTEDVALUE ( Table1[institution] ),
    "A", CALCULATE (
        COUNT ( Table1[Column] ),
        FILTER ( ALL ( Table1 ), Table1[Column] = "G" )
    ),
    "B", CALCULATE (
        COUNT ( Table1[Column] ),
        FILTER ( ALL ( Table1 ), Table1[Column] = "K" )
    )
)

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Excellent solution thank you.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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