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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

exists in same table

hi, i'm new to Power BI...

not sure if i need a calculated column or a measure.

I want to check for each row if another row exists where value in column A is the same as this row and value in column B is 1.

so basically I would have a new boolean column.

or, optionally to have a new table with distinct columns A, B and the new bool column.

 

how should i do that in DAX and sould it be a column or a measure?

thanks

1 ACCEPTED SOLUTION

@Anonymous ,

 

Create two measures using DAX below:

count with true = CALCULATE(DISTINCTCOUNT('Table'[A]), FILTER(ALLEXCEPT('Table', 'Table'[B]), 'Table'[C] = TRUE()))
count with false = CALCULATE(DISTINCTCOUNT('Table'[A]), FILTER(ALLEXCEPT('Table', 'Table'[B]), 'Table'[C] = FALSE()))

Capture.PNG 

 

Community Support Team _ Jimmy Tao

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

5 REPLIES 5
PattemManohar
Community Champion
Community Champion

@Anonymous  You can use a conditional column to flag row alreayd exists or not. But it will be great if you can post some sample data and expected output to suggest an accurate solution.





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

Proud to be a PBI Community Champion




Anonymous
Not applicable

thank you @PattemManohar !

lets say i have the following data:  (ignore column D, it's only to show that data is distinct)

 

ex.png

 

 

 

 

 

 

(of course real data is much bigger)

I need a report (or a graph) that will count distinct countries for each president that have at least one true value in column C.  and a count of countries without any true value.

so the report would be like that:

 

ex2.png

 

 

I guess there are a few ways to do that, but i'm not sure how...

Thanks a lot

 

I know my original question didn't mention all that Smiley Happy  I was just trying to simplify

@Anonymous  Please follow below steps:

 

Add a new column in the source table as below. This is to flag all the states as True if it contains atleast one True value.

 

 

CheckFlag = 
VAR _CurrState = Test191Lkp[State]
VAR _CurrPresident = Test191Lkp[President]
VAR _Result = LOOKUPVALUE(Test191Lkp[Flag],Test191Lkp[State],_CurrState,Test191Lkp[President],_CurrPresident,Test191Lkp[Flag],TRUE)
RETURN IF(ISBLANK(_Result),"F","T")

 

 

The result will now looks like..

 

image.png

 

Now create a new table as below which will use the above table as input.

 

Test191Out = 
VAR _True = SUMMARIZE(FILTER(Test191Lkp,Test191Lkp[CheckFlag]="T"),Test191Lkp[President],"TrueCount",DISTINCTCOUNT(Test191Lkp[State]),"Type","True")
VAR _False = SUMMARIZE(FILTER(Test191Lkp,Test191Lkp[CheckFlag]="F"),Test191Lkp[President],"FalseCount",DISTINCTCOUNT(Test191Lkp[State]),"Type","False")
RETURN UNION(_True,_False)

The output will be 

 

image.png

 

Now you can see the Matrix visual to represent this data in your required fashion.

 

image.png

 

 





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

Proud to be a PBI Community Champion




@Anonymous ,

 

Create two measures using DAX below:

count with true = CALCULATE(DISTINCTCOUNT('Table'[A]), FILTER(ALLEXCEPT('Table', 'Table'[B]), 'Table'[C] = TRUE()))
count with false = CALCULATE(DISTINCTCOUNT('Table'[A]), FILTER(ALLEXCEPT('Table', 'Table'[B]), 'Table'[C] = FALSE()))

Capture.PNG 

 

Community Support Team _ Jimmy Tao

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

Anonymous
Not applicable

@PattemManohar and @v-yuta-msft great thanks!!

(i think i'm missing the accept bottun... where is it?)

found it Robot LOL

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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