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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
romoguy15
Helper IV
Helper IV

Group Column of locations based on condition from another column

Hi,

 

I have been working to try and come up with a calculated column that can tell me if my list of locations meets a specific condition with a Yes/No statement.

 

I have a list of locatins with a column of different tickets. The locations are listed more than once but can have two different types of tickets. I am trying to group the locations to say if Location has a PSU and a Non NWR Ticket, "Yes", if not then "No". The calculation column it tried using below as well as several other attempts but it seems i'm not fully understanding how to achieve it.

 
 = CALCULATE(IF(FILTER(ALL('Sample'[Location], 'Sample'[Ticket]), 'Sample'[Ticket] = "PSU" && "Non NWR"), "Yes", "No"))

 

Below is the sample data

https://1drv.ms/u/s!AqID1H0nHPOzhAoeXiSYdvCbmb-e?e=4iU40P

 

Attached is an example snip from excel of what I am getting at

romoguy15_0-1618432157101.png

I appreciate the support and any input I can get.

 

Thank you

2 ACCEPTED SOLUTIONS
mahoneypat
Microsoft Employee
Microsoft Employee

Here is a column expression that shows one way to do it.

 

Has Both =
VAR vResult =
    CALCULATE (
        DISTINCTCOUNT ( 'Sample'[Ticket] ),
        ALLEXCEPT ( 'Sample', 'Sample'[Location] ),
        'Sample'[Ticket] IN { "PSU""Non NWR" }
    )
RETURN
    IF ( vResult = 2"Y""N" )

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

Anonymous
Not applicable

Here's a faster version that does not rely on CALCULATE:

 

// T is the name of your table.

[Your Column] = // calculated column
var CurrentLocation = T[Location]
var TicketTable = {"psu", "non nwr"}
var Yes =
    2 = COUNTROWS(
        filter(
            ALL( T[Location], T[Ticket] ),
            T[Location] = CurrentLocation
            &&
            T[Ticket] in TicketTable
        )
    )
return
    if( Yes, "Yes", "No" )

View solution in original post

3 REPLIES 3
romoguy15
Helper IV
Helper IV

@mahoneypat & @Anonymous  thank you both for the solution. Not that I would have figured out the entire equation but I did not stop to think of using VAR. Thank you.

mahoneypat
Microsoft Employee
Microsoft Employee

Here is a column expression that shows one way to do it.

 

Has Both =
VAR vResult =
    CALCULATE (
        DISTINCTCOUNT ( 'Sample'[Ticket] ),
        ALLEXCEPT ( 'Sample', 'Sample'[Location] ),
        'Sample'[Ticket] IN { "PSU""Non NWR" }
    )
RETURN
    IF ( vResult = 2"Y""N" )

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Here's a faster version that does not rely on CALCULATE:

 

// T is the name of your table.

[Your Column] = // calculated column
var CurrentLocation = T[Location]
var TicketTable = {"psu", "non nwr"}
var Yes =
    2 = COUNTROWS(
        filter(
            ALL( T[Location], T[Ticket] ),
            T[Location] = CurrentLocation
            &&
            T[Ticket] in TicketTable
        )
    )
return
    if( Yes, "Yes", "No" )

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors