cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ItSupportElm
Helper III
Helper III

Show only one value for same Id else leave it blank

Hello,

 

I have an issue on my report and i dont know how to do it,

 

i have this table : 

 

IdRole     NameRole
1    AA
2    AB
3    AC

 

And this second table :

 

IdUser    IdRole
1    1
1    2
2    1
3

    3

 

And i have my last table for example with somes informations : 

IdUserDatePointNameRole
103/05/2021 500AA
101/05/2021 500AA
203/03/2020 800Blank
317/02/20201000Blank

 

I want to have this last colum as a result, The User have many role but the only Role that im interested is to know if he have "AA" role else leave it blank.

 

Im in DirectQuery if someone can help me please.

 

Thank you for the futur answer.

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@ItSupportElm,

 

Try this solution.

 

1. Create a Users table (one row per user).

2. Create a data model as shown below.

 

DataInsights_0-1620135189042.png

 

3. Create a calculated column in table UserPoints:

 

NameRole = 
VAR vRowCount =
    CALCULATE ( COUNTROWS ( UserRoles ), Roles[NameRole] = "AA" )
VAR vResult =
    IF ( vRowCount > 0, "AA" )
RETURN
    vResult

 

Result:

 

DataInsights_1-1620135274338.png

 

Your example shows Blank for IdUser2, but this user has role "AA". This is why my result is slightly different from yours.





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

Proud to be a Super User!




View solution in original post

1 REPLY 1
DataInsights
Super User
Super User

@ItSupportElm,

 

Try this solution.

 

1. Create a Users table (one row per user).

2. Create a data model as shown below.

 

DataInsights_0-1620135189042.png

 

3. Create a calculated column in table UserPoints:

 

NameRole = 
VAR vRowCount =
    CALCULATE ( COUNTROWS ( UserRoles ), Roles[NameRole] = "AA" )
VAR vResult =
    IF ( vRowCount > 0, "AA" )
RETURN
    vResult

 

Result:

 

DataInsights_1-1620135274338.png

 

Your example shows Blank for IdUser2, but this user has role "AA". This is why my result is slightly different from yours.





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

Proud to be a Super User!




Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.

Top Solution Authors
Top Kudoed Authors