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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
JGARROD
Helper I
Helper I

If a certain filter is applied return 1, if a different filter is applied return 2

HI, 

 

I have a column within a tbale that contins 3 distinct values Red, Green, Blue across 1500 rows. 

 

I need a dax measure that i can apply to a card that when the table is filtered on Red returns the number 1, when it is filtered on blue returns the number 2 and green returns the number 3. 

 

Is this possible and if so how?

 

Thanks in advance! 

 

Jack 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

I tried to create a sample pbix file like below.

 

Jihwan_Kim_0-1666258790948.png

 

 

Expected result measure: =
SWITCH (
    SELECTEDVALUE ( Category[Color] ),
    "Red", 1,
    "Blue", 2,
    "Green", 3,
    "select one color"
)

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

I tried to create a sample pbix file like below.

 

Jihwan_Kim_0-1666258790948.png

 

 

Expected result measure: =
SWITCH (
    SELECTEDVALUE ( Category[Color] ),
    "Red", 1,
    "Blue", 2,
    "Green", 3,
    "select one color"
)

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

speedramps
Super User
Super User

Try this 

Colour number =
SWITCH(SELECTEDVALUE('Table'[Colour]),
"Red",1,
"Blue",2,
"Green",3
)
 

Thanks for reaching out for help.

I put in a lot of effort to help you, now please quickly help me by giving kudos.

Remember we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button. 

If you give someone a fish then you only give them one meal, but if you teach them how to fish then they can feed themselves and teach others for a lifetime.  I prefer to teach members on this forum techniques rather give full solutions and do their job. You can then adapt the technique for your solution, learn some DAX skills for next time and soon become a Power BI Super User like me. 

One question per ticket please. If you need to extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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