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
CCAd
Frequent Visitor

calculation based on the number of times a value appears in multiple columns

Hi,

 

I need expert help please. I have two columns with agent names. I want to be able to assign 1 point if there is only agent 1 and no agent 2 in each row and assign 0.5 to each agent in column 1 and 2 if there are agent names in both columns. I also want to be able to filter each agent to show their stats. Sample table is below:

 

Agent 1Agent 2Date
Brad cooper 2-Jun-23
Brad cooper 2-Jun-23
Tim Cruz 5-Jun-23
Mansoor AhmedDavid Watson14-Jun-23
Brad cooper 1-Jun-23
Brad cooper 15-Jun-23
Brad cooper 29-Jun-23
Brad cooper 30-Jun-23
Dipti Malhotra 2-Jun-23
Djokovich 5-Jun-23
Mansoor Ahmed 6-Jun-23
Djokovich 13-Jun-23
Djokovich 20-Jun-23
Djokovich 21-Jun-23
George Matthews 27-Jun-23
Tim CruzDipti Malhotra26-Jun-23
Tim CruzJohn Smith6-Jun-23
Tim CruzBrendan Sarroff6-Jun-23
Jacob SieverTim Cruz6-Jun-23
John SmithTim Cruz9-Jun-23
John SmithDipti Malhotra14-Jun-23
John SmithDjokovich15-Jun-23
John SmithMatt C.29-Jun-23
Jacob Siever 5-Jun-23
Brendan Sarroff 6-Jun-23
George Matthews 26-Jun-23
George Matthews 26-Jun-23
Brad cooper 28-Jun-23
Tim Cruz 30-Jun-23
Tim Cruz 30-Jun-23
David Watson 30-Jun-23
John Smith 6-Jun-23
Tim Cruz 20-Jun-23
Jacob Siever 30-Jun-23
Djokovich 13-Jun-23
Djokovich 13-Jun-23

 

Additionally, can you please also advise how I can create one slicer that is able to show me the selected agent from both agent 1 and agent 2 columns?

 

Thanks in advance!

1 ACCEPTED SOLUTION
BIswajit_Das
Resolver III
Resolver III

Hello @CCAd  You can create a calculated column to acheive what you need
I.e

Column =
VAR _a = [Agent 1]
VAR _b = [Agent 2]
RETURN
IF(_a <> BLANK() && _b = BLANK(),1,IF(_a <> BLANK() && _b <> BLANK(),0.5,0))
and
About the slicer you can choose the "New Column" to get the identification.
C2.PNG
c3.PNG

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

Please find attached my PBI file.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
CCAd
Frequent Visitor

Hi @BIswajit_Das Thank you for your response. I was able to setup a conditional column in PQ for the points. However, I still cant figure out a way to have unique agent names in a slicer that would show me the selected agents' stats whether they appear in the agent 1 or agent 2 columns. If there are two agents assigned to the record, each one of them should get 0.5 points, otherwise 1 point assigned to agent 1 in that case. 

 

For e.g., Djokovich, who appears in both columns, has a total count of 7 but the actual score, as per the data should be 6.5. I want to be able to calculate individual agents' score based on this approach and be able to plot in a bar graph too, individually and collectively.

 

I just hope I am making some sense.

BIswajit_Das
Resolver III
Resolver III

Hello @CCAd  You can create a calculated column to acheive what you need
I.e

Column =
VAR _a = [Agent 1]
VAR _b = [Agent 2]
RETURN
IF(_a <> BLANK() && _b = BLANK(),1,IF(_a <> BLANK() && _b <> BLANK(),0.5,0))
and
About the slicer you can choose the "New Column" to get the identification.
C2.PNG
c3.PNG

Hey Mate,

 

just discovered that your solution gives correct combined results for Agent 1 but when I look at the results for each agent individually, the numbers dont add up. For instance, David Watson should have a total of 1.5 points but I am only seeing 1. IS there anyway I can show the totals based on unique ID (there is a column for that) and also be able to show each agent's individual totals based on agent 1 and agent 2 columns?

 

Thanks again

Hi @BIswajit_Das ,

 

Can i do this with a measure? My table name is Appraisal.

 

@Ashish_Mathur thanks for your contribution too mate. However, I would really appreciate it if you can advise of a measure instead of calculated columns because the structure of the file might change but I would still be able to apply the measure (and also use it in other files).

 

Thanks

You are welcome.  Are you OK with the Unpivoting step?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.