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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
newpi
Helper V
Helper V

Return values only if users don't belong to any group

I have the following table 

1User nameUser groupOutput Column
2User 1  
3User 1Group AGroup A
4User 1Group BGroup B
5User 2 User 2
6User 3Group AGroup A

 

Basically I want my output column to show groups or users only if they do no belong to any group. For example above.

User 1 has a null row in the 2nd line but User 1 also belongs to Group A & Group B. So in my output I do not want to have User 1 as value in the 2nd row . Similarly, User 2 does not belong to any group so I want to show User 2 as value in my output column.

1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

Hi @newpi ,

 

Create a Calculated Column

 

Op Column = 
var a = CALCULATE(Count('Table'[User name]), FILTER('Table', 'Table'[User name] = EARLIER('Table'[User name])))
RETURN
IF(a = 1  && 'Table'[User group] = BLANK(), 'Table'[User name], 'Table'[User group])

 

1.jpg

 

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@newpi , Try a new column like

 

Output Column =
var _1 = countx(filter(table,[User name] =earlier([User name]),[User group]))+0

return
switch( true() ,
isblank([User group]) && blank(_1)=0, [User name],
isblank([User group]) && blank(_1)>=0, blank(),
[User group]
)

harshnathani
Community Champion
Community Champion

Hi @newpi ,

 

Create a Calculated Column

 

Op Column = 
var a = CALCULATE(Count('Table'[User name]), FILTER('Table', 'Table'[User name] = EARLIER('Table'[User name])))
RETURN
IF(a = 1  && 'Table'[User group] = BLANK(), 'Table'[User name], 'Table'[User group])

 

1.jpg

 

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Thanks @harshnathani this works. Only. 1 question though, I'm still trying to understand the formula but because of earlier function or anything else in the measure, is it necessary that all user 1 rows should be in sequence (row 2,3,4 here)? The same user can also be out of sequence right? meaning on rows (2,3 & 5).

Also is there a way to not show up blank in the filter slicer? Screen Shot 2020-08-20 at 1.09.37 PM.png

HI @newpi ,

 

Yes, it can be out of sequence.

 

To understand the EARLIER formula, please see this video.

 

https://www.youtube.com/watch?v=lyhS2txtZ44&vl=en

 

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Thanks @harshnathani The formula is also creating blanks (which we want it to) and grouping all user 1 under that blank and showing blank as a value in the slicer. Anyway to get rid of that? 

Hi @newpi ,

 

Use the Visual Filter

 

1.jpg

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.