Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Dinamic title - if condition

Hello,

I am new to this forum but I couldn't find any similar thread with the problem I am facing.

So I have a card which I want to have a dinamic title. I already went to conditional formating function for the title but I am not very experinced with the query functions.
I have a slicer and I was able to create a title with the name of the chosen category on that slicer:

Dynamic Title =
"Category is " &SELECTEDVALUE(Table[Category])

But my goal is to present a specific string hardcoded on the title when one of the four categories is chosen on the slicer. So on the function I want to have four conditional lines to parse what Category was chosen and have a different title based on that.
Example:
If Category 1 is chosen: Text one.
If Category 2 is chosen: Text two..
If Category 3 is chosen: Text three.
If Category 4 is chosen: Text four.

Is there any possibility to do this?

Thank you in advance for your time!!

Best regards
  • Anonymous  Yes, you can achive this with the SWITCH function. Here is my solution. Hope this works for your requirement.

    1. Create a measure in the similar fashion with your required text.

     

    Text Based on Category = SWITCH(
    TRUE(),
    MIN('DataTable'[Category]) = "Category 1", "Text One",
    MIN('DataTable'[Category]) = "Category 2", "Text Two",
    MIN('DataTable'[Category]) = "Category 3", "Text Three",
    MIN('DataTable'[Category]) = "Category 4", "Text Four"
    )

    2. Once the measure is created put it in the card visual and here is the result.

     

     

    ** If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution, so that it comes in top of the search and help others. Thank you !

    Good Luck 👍

     

3 Replies

  • ghoshabhijeet's avatar
    ghoshabhijeet
    Solution Supplier

    Anonymous  Yes, you can achive this with the SWITCH function. Here is my solution. Hope this works for your requirement.

    1. Create a measure in the similar fashion with your required text.

     

    Text Based on Category = SWITCH(
    TRUE(),
    MIN('DataTable'[Category]) = "Category 1", "Text One",
    MIN('DataTable'[Category]) = "Category 2", "Text Two",
    MIN('DataTable'[Category]) = "Category 3", "Text Three",
    MIN('DataTable'[Category]) = "Category 4", "Text Four"
    )

    2. Once the measure is created put it in the card visual and here is the result.

     

     

    ** If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution, so that it comes in top of the search and help others. Thank you !

    Good Luck 👍

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you very much ghoshabhijeet!
      This was exactly what I was looking 😀

      Regards.