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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
mjohnsonsmi
Frequent Visitor

If statement to show one salesman's name vs sales manager based on filters

Hello, 

 

I have to be missing something silly here. I can't find anything online or in the boards that fits my specific quirk.

 

I have a dashboard that show's a salesman's metrics for his territory. Since this report can be printed for them to hand off it needs to display their name. A sales manager doesn't have a territory assigned so he can see everyone's information.

 

What I'm trying to do is an if statement that determines if 1 salesman is selected (since each guy can only see their information) to show that name. If more than one is selected (like when the sales manager is looking at all territories) it shows his name.

 

My logic is...

If NumberOfSelectedSalesman > 1

Show Sales Manager,

Show Salesman

 

 

 

This is my code. It counts all 5 salesmen no matter the filter selection, so it always shows the sales manager. Thoughts? 

 

SelectedSalesman =
VAR SelectedSalesman =
VALUES ( Table[SalesmanName] )
VAR NumberOfSelectedSalesman =
CALCULATE ( COUNTROWS ( SelectedSalesman ) )
RETURN
NumberOfSelectedSalesman // Used for troubleshooting, shows 5 salesmen selected
& IF (
NumberOfSelectedSalesman > 1,
"Sales Manager",
Table[SalesmanName]
)

1 ACCEPTED SOLUTION

Well, my life got easier all of a sudden. This requirement is no longer needed. Thank you though!

View solution in original post

6 REPLIES 6
ricardocamargos
Continued Contributor
Continued Contributor

Hi @mjohnsonsmi,

 

Could you provide a dataset as sample ?

 

Thanks,

 

Ricardo

Sure thing, sorry.

 

VARs

  • SelectedSalesman I've tried as a measure and a column
  • NumberOfSelectedSalesman is supposed to count the number of selected rows of the salesman table (I suspect the problem is on this one)

Salesman Table

  1. Bob
  2. Sam
  3. Tyler
  4. Joe
  5. Chris

Hi @mjohnsonsmi,

 

Try this code:

 

_Salesman =
VAR selected = ALLSELECTED(Table1[Salesman])
VAR returnValue = IF(COUNTROWS(selected) > 1; "Sales Manager"; DISTINCT(Table1[Salesman]))
RETURN
returnValue

 

Ricardo

Thank you Ricardo, unfortunately it's doing the same behavior. It only shows the sales manager no matter what's selected. I had to change the semicolons in the IF to commas also (for anyone reading this).

 

Something I forgot to mention, the salesman field that does the filtering has many records in the table. Sales records with the owner (salesman) indicated, although there are only the 5 distinct salesman names.

Hi @mjohnsonsmi.

 

Can u provide a print of your screen, with your visual and slicers (current and what u want) ?

 

 

Ricardo

Well, my life got easier all of a sudden. This requirement is no longer needed. Thank you though!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.