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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
vhsn
Frequent Visitor

Using measure to check if even one value is true, then all of that value is true

 

CategoryMeasure1
AN
AY
AN
AN
BN
BN
BN
CN
CN
CN
CY
DN
DN

 

I'd like to use a measure to check: if even one category has Y, then all of that category is true, else false

 

For A = True, B = False, C = True, D = False

 

Thank you for the help

1 ACCEPTED SOLUTION

Let me suggest you a different approach then. Write a new measure called Exclude Month_Numerical : IF( MAX(table[Month]) IN ALLSELECTED(sample[Month]) && COUNTROWS(ALLSELECTED(sample[Month])) <> COUNTROWS(ALL(sample[Month])), 1,0)

 

Basically we are replacing Y/N with binary values that we can add.

Then, write a measure like this:

CategoryY/N = IF(SUMX('Table where "Exclude Month_Numerical" is hosted, [Exclude Month_Numerical]) >= 1, "True", "False")

 

This way we'll be adding up the results of the measures in each row, since we only deal with 0s and 1s works as if we were counting.

Let me know if it works. 





Did I answer your question? Give your kudos and mark my post as a solution!

Proud to be a Super User!





View solution in original post

4 REPLIES 4
ray_aramburo
Super User
Super User

I would suggest something like this:

Instead of creating a measure to evaluate the first Y/N, create a conditional column (either on Power Query or as a calculated column) and call it "Yes/No?" Then:

Category Result =

VAR count_result = CALCULATE(COUNT('Table'[Yes/No?]), 'Table'[Yes/No?] = "Y")

RETURN

IF(count_result >= 1, "True", "False")

 

Then, create a table visual and add Category column and created measure.

 





Did I answer your question? Give your kudos and mark my post as a solution!

Proud to be a Super User!





The first measure is to exclude data that is in the currently selected slicer. I think I need that to be a measure to work properly? Unless.. is there a way to make the first measure also account for the category...?

 

Here is the extended sample:

CategoryMonthMeasure1
AMayN
AJuneY
AJulyN
AAugustN
BJanuaryN
BMarchN
BAprilN
CFebruaryN
CMarchN
CMayN
CJuneY
DMarchN
DAprilN

 

My current measure:

Exclude Month =
IF(
    MAX(table[Month]) IN ALLSELECTED(sample[Month]) && COUNTROWS(ALLSELECTED(sample[Month])) <> COUNTROWS(ALL(sample[Month])),
    "Y","N")

Let me suggest you a different approach then. Write a new measure called Exclude Month_Numerical : IF( MAX(table[Month]) IN ALLSELECTED(sample[Month]) && COUNTROWS(ALLSELECTED(sample[Month])) <> COUNTROWS(ALL(sample[Month])), 1,0)

 

Basically we are replacing Y/N with binary values that we can add.

Then, write a measure like this:

CategoryY/N = IF(SUMX('Table where "Exclude Month_Numerical" is hosted, [Exclude Month_Numerical]) >= 1, "True", "False")

 

This way we'll be adding up the results of the measures in each row, since we only deal with 0s and 1s works as if we were counting.

Let me know if it works. 





Did I answer your question? Give your kudos and mark my post as a solution!

Proud to be a Super User!





That works! Thank you!

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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