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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Dudeman123
New Member

Data table in variable

Hi i have a query 

So I have 5 columns called objective 1, objective 2,... Objective 5. Which holds values yes or no.

I have 3 other columns called category A, category B, category C.

Now this holds data on applications

The goal is to count the number of objectives which has value "No".

So if category A is "Yes" then I have to count the number of no's from objective 1,2,4

If category B is "Yes" then I have to count number of no's from objective 1,2,5

And category C it's 1,5.

Issue is an application can have multiple categories so I don't want to duplicate the count.

So if it's category A and B is Yes then I should count 1,2,4,5 no of "No".

I tried using data table where I store each objective number as a variable for each category and then perform union and distinct. But it's throwing me an error.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Dudeman123 ,

Thanks for bhanu_gautam's reply!

And @Dudeman123 , here may be a simpler DAX. Here is my sample data:

vjunyantmsft_0-1738895579466.png

Then use this DAX to create a measure:

Count No = 
SUMX(
    Applications,
    VAR CatA = Applications[Category A] = "Yes"
    VAR CatB = Applications[Category B] = "Yes"
    VAR CatC = Applications[Category C] = "Yes"
    RETURN
    IF( CatA || CatB || CatC, IF( Applications[Objective 1] = "No", 1, 0 ) ) +
    IF( CatA || CatB, IF( Applications[Objective 2] = "No", 1, 0 ) ) +
    IF( CatA, IF( Applications[Objective 4] = "No", 1, 0 ) ) +
    IF( CatB || CatC, IF( Applications[Objective 5] = "No", 1, 0 ) )
)

And the final output is as below:

vjunyantmsft_1-1738895650205.png


Best Regards,
Dino 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

2 REPLIES 2
Anonymous
Not applicable

Hi @Dudeman123 ,

Thanks for bhanu_gautam's reply!

And @Dudeman123 , here may be a simpler DAX. Here is my sample data:

vjunyantmsft_0-1738895579466.png

Then use this DAX to create a measure:

Count No = 
SUMX(
    Applications,
    VAR CatA = Applications[Category A] = "Yes"
    VAR CatB = Applications[Category B] = "Yes"
    VAR CatC = Applications[Category C] = "Yes"
    RETURN
    IF( CatA || CatB || CatC, IF( Applications[Objective 1] = "No", 1, 0 ) ) +
    IF( CatA || CatB, IF( Applications[Objective 2] = "No", 1, 0 ) ) +
    IF( CatA, IF( Applications[Objective 4] = "No", 1, 0 ) ) +
    IF( CatB || CatC, IF( Applications[Objective 5] = "No", 1, 0 ) )
)

And the final output is as below:

vjunyantmsft_1-1738895650205.png


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

bhanu_gautam
Super User
Super User

@Dudeman123 Create a calculated column for each category to identify the relevant objectives:

DAX
CategoryA_Objectives =
IF([Category A] = "Yes",
IF([Objective 1] = "No", 1, 0) +
IF([Objective 2] = "No", 1, 0) +
IF([Objective 4] = "No", 1, 0),
0
)

CategoryB_Objectives =
IF([Category B] = "Yes",
IF([Objective 1] = "No", 1, 0) +
IF([Objective 2] = "No", 1, 0) +
IF([Objective 5] = "No", 1, 0),
0
)

CategoryC_Objectives =
IF([Category C] = "Yes",
IF([Objective 1] = "No", 1, 0) +
IF([Objective 5] = "No", 1, 0),
0
)

 

Create a measure to count the distinct "No" values across the objectives for each application:

 

DAX
DistinctNoCount =
VAR ObjectivesA =
IF([Category A] = "Yes",
UNION(
SELECTCOLUMNS(FILTER(ALL('Table'), [Objective 1] = "No"), "Objective", 1),
SELECTCOLUMNS(FILTER(ALL('Table'), [Objective 2] = "No"), "Objective", 2),
SELECTCOLUMNS(FILTER(ALL('Table'), [Objective 4] = "No"), "Objective", 4)
),
BLANK()
)

VAR ObjectivesB =
IF([Category B] = "Yes",
UNION(
SELECTCOLUMNS(FILTER(ALL('Table'), [Objective 1] = "No"), "Objective", 1),
SELECTCOLUMNS(FILTER(ALL('Table'), [Objective 2] = "No"), "Objective", 2),
SELECTCOLUMNS(FILTER(ALL('Table'), [Objective 5] = "No"), "Objective", 5)
),
BLANK()
)

VAR ObjectivesC =
IF([Category C] = "Yes",
UNION(
SELECTCOLUMNS(FILTER(ALL('Table'), [Objective 1] = "No"), "Objective", 1),
SELECTCOLUMNS(FILTER(ALL('Table'), [Objective 5] = "No"), "Objective", 5)
),
BLANK()
)

VAR AllObjectives =
UNION(
COALESCE(ObjectivesA, SELECTCOLUMNS({}, "Objective", BLANK())),
COALESCE(ObjectivesB, SELECTCOLUMNS({}, "Objective", BLANK())),
COALESCE(ObjectivesC, SELECTCOLUMNS({}, "Objective", BLANK()))
)

RETURN
COUNTROWS(SUMMARIZE(AllObjectives, [Objective]))




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

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.