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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Calculate occurence based on multiple colomns filters

Hi Team 

 

I have below dataset: 

 

CityValue1Value2
DelhiYes 
DelhiNoNa
DelhiNoYes
DelhiNANo
MumbaiYesNo
MumbaiYesNo
MumbaiNoNA
MumbaiNoNA
BangaloreYesna
Bangalorenona
BangaloreNo 
BangalorenoYes

 

I want to return below output in a card visual using measure :

 

No of locations where Value1 and value2 is Yes , output would be 2 here

Delhi and Bangalore has Value1 and Value2 Yes where mumbai has Value 1 yes but no rows has value2 as yes.

 

@Greg_Deckler @tamerj1 @johnt75 @Jihwan_Kim @Wilson_ 

1 ACCEPTED SOLUTION

hi @Anonymous 

the data is exactly from you and i only name it as data. all others are included in the previous replies. 

View solution in original post

6 REPLIES 6
FreemanZ
Super User
Super User

hi @Anonymous 

try to plot a card visual with a measure like:

Measure = 
VAR _table = 
    ADDCOLUMNS(
        VALUES(Data[City]),
        "Value1",
        CALCULATE(MAX(Data[Value1])),
        "Value2",
        CALCULATE(MAX(Data[Value2]))
    )
RETURN
    COUNTROWS(
        FILTER(
            _table,
            [Value1]="Yes"&&[Value2]="Yes"
        )
    )

it worked like:

FreemanZ_0-1682337369464.png

Anonymous
Not applicable

Thank you for the promt response unfortunately its not working. I just gave dummy data but Value1 and value2 has other data apart from NA, No so Max fucntion is capturing those values instead Yes.

 

how to explicit call Yes as Max fucntion giving some other output

 

@FreemanZ 

hi @Anonymous 

then try like:

Measure = 
VAR _table = 
    GENERATE(
        VALUES(Data[City]),
        CALCULATETABLE(
            CROSSJOIN(VALUES(Data[Value1]), VALUES(Data[Value2]))
        )
    )
RETURN
    COUNTROWS(
        FILTER(
            _table,
            [Value1]="Yes"&&[Value2]="Yes"
        )
    )

 

it worked like:

FreemanZ_0-1682338595922.png

Anonymous
Not applicable

Can you please share the pbix if possible?  @FreemanZ 

hi @Anonymous 

the data is exactly from you and i only name it as data. all others are included in the previous replies. 

Anonymous
Not applicable

Its working, thanks buddy!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.