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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
tristanweeks47
Frequent Visitor

IF and AND statements

Hello, 
I am trying to show UPRNS that have account type Closed AND Connection. 
Please see screenshot below...
The UPRNS is a list of duplicates. I want to show only the UPRNS of the account that have closed and then there is a connection after. How do i go about this? Thank you 

tristanweeks47_0-1699616927122.png

 

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @tristanweeks47 ,

 

Please try code as below to create a measure to filter your visual.

Measure = 
VAR _TYPE_LIST = CALCULATETABLE(VALUES('Table'[Account Type]),ALLEXCEPT('Table','Table'[UPRN]))
RETURN
IF("Closed" in _TYPE_LIST && "Connection" in _TYPE_LIST ,1,0)

Sample:

vrzhoumsft_0-1699853332762.png

Add this measure into visual level filter and set it to show items when value = 1.

vrzhoumsft_1-1699853367601.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @tristanweeks47 ,

 

Please try code as below to create a measure to filter your visual.

Measure = 
VAR _TYPE_LIST = CALCULATETABLE(VALUES('Table'[Account Type]),ALLEXCEPT('Table','Table'[UPRN]))
RETURN
IF("Closed" in _TYPE_LIST && "Connection" in _TYPE_LIST ,1,0)

Sample:

vrzhoumsft_0-1699853332762.png

Add this measure into visual level filter and set it to show items when value = 1.

vrzhoumsft_1-1699853367601.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Dangar332
Memorable Member
Memorable Member

HI, @tristanweeks47 

try below code 

adjust column name and table name
logic work below

Measure = 
var a1 = CALCULATE(max('Table'[Column1]),FILTER('Table', 'Table'[Column2]=2))
var b1 = CALCULATE(max('Table'[Column1]),FILTER('Table', 'Table'[Column2]=1))
return 
CALCULATE(MAX('Table'[Column1]),
 'Table'[Column1]=a1 && 'Table'[Column1]=b1,ALLEXCEPT('Table','Table'[Column2]))

 

sample data i have taken

Dangar332_1-1699619464843.png

 

result of measure

 

Dangar332_0-1699619442336.png

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors