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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Oros
Post Prodigy
Post Prodigy

Format value based on selection

 Hello,
 
What would be the correct measure to use, if I would like to highlight from the TOP N products only the ones that were sold by the selected salesperson?  I have dropdown selector for TOP N, as well another dropdown selector for Salesperson.
Thanks.

 



 

Oros_0-1734720778713.png

 

3 ACCEPTED SOLUTIONS
Ritaf1983
Super User
Super User

Hi @Oros 
You should create a names table that is not connected to the transactions table :

Ritaf1983_1-1734767077972.png

and then create Dax with crossjoin inside for marker's color :

color =
VAR SelectedNames = VALUES(Names[Name])
VAR ProductsFromSelectedNames =
    DISTINCT(
        FILTER(
            CROSSJOIN(Names, fruits),
            'fruits'[Name] IN SelectedNames
        )
    )
VAR CurrentProduct = SELECTEDVALUE(fruits[Product])
RETURN
    IF(
        CurrentProduct IN SELECTCOLUMNS(ProductsFromSelectedNames, "Product", fruits[Product]),
    "Yellow",
        0
    )
Use names table for the slicer:
Ritaf1983_2-1734767208516.png

Use a measure that we created for the conditional formatting

Ritaf1983_3-1734767503844.png

Result:

Ritaf1983_4-1734767543829.png

 

Will work with top n logic in the same way.

pbix is attached

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

v-jiewu-msft
Community Support
Community Support

Hi @Oros ,

Based on the description, the method Ritaf1983 provided should be helpful

Besides, try using the following DAX formula to filter the top n product.

Product Rank = RANKX(ALL('Table'), [Total number], , DESC, Dense)
TopN filter = 
   VAR SelectedTopN = SELECTEDVALUE('Table top n'[TopN])
   RETURN
       IF([Product Rank] <= SelectedTopN, 1, 0)

Drag the measure to the Filters pane and set the show item is 1.

vjiewumsft_0-1734945831228.png

Then, drag the sales person to the slicer visual and select the person.

vjiewumsft_1-1734945880775.png

Best Regards,

Wisdom Wu

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

Hi @v-jiewu-msft,

 

Thank you so much for helping.  Your solution works as well! 

View solution in original post

7 REPLIES 7
v-jiewu-msft
Community Support
Community Support

Hi @Oros ,

Based on the description, the method Ritaf1983 provided should be helpful

Besides, try using the following DAX formula to filter the top n product.

Product Rank = RANKX(ALL('Table'), [Total number], , DESC, Dense)
TopN filter = 
   VAR SelectedTopN = SELECTEDVALUE('Table top n'[TopN])
   RETURN
       IF([Product Rank] <= SelectedTopN, 1, 0)

Drag the measure to the Filters pane and set the show item is 1.

vjiewumsft_0-1734945831228.png

Then, drag the sales person to the slicer visual and select the person.

vjiewumsft_1-1734945880775.png

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-jiewu-msft,

 

Thank you so much for helping.  Your solution works as well! 

Ritaf1983
Super User
Super User

Hi @Oros 
You should create a names table that is not connected to the transactions table :

Ritaf1983_1-1734767077972.png

and then create Dax with crossjoin inside for marker's color :

color =
VAR SelectedNames = VALUES(Names[Name])
VAR ProductsFromSelectedNames =
    DISTINCT(
        FILTER(
            CROSSJOIN(Names, fruits),
            'fruits'[Name] IN SelectedNames
        )
    )
VAR CurrentProduct = SELECTEDVALUE(fruits[Product])
RETURN
    IF(
        CurrentProduct IN SELECTCOLUMNS(ProductsFromSelectedNames, "Product", fruits[Product]),
    "Yellow",
        0
    )
Use names table for the slicer:
Ritaf1983_2-1734767208516.png

Use a measure that we created for the conditional formatting

Ritaf1983_3-1734767503844.png

Result:

Ritaf1983_4-1734767543829.png

 

Will work with top n logic in the same way.

pbix is attached

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi @Ritaf1983,

 

Thank you so much for helping.  Your solution works!

Happy to help 🌷

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
danextian
Super User
Super User

You will need to use a disconnected table  containing a column of person name. You can create one using DAX

PersonsDisconnected = DISTINCT ( DataTable[Person] )

And then a conditional formatting measure

IF (
    NOT (
        ISBLANK (
            CALCULATE (
                COUNTROWS ( DataTable ),
                KEEPFILTERS ( TREATAS ( PersonsDisconnected, DataTable[Person] ) )
            )
        )
    ),
    "yellow"
)

From the conditional formatting options, select field value and then this measure.










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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
lbendlin
Super User
Super User

Most likely this will require disconnected tables.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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