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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Dominik-1988
New Member

Add up and evaluate

Hello everyone,

I need help with a code in Power Bi.
I have 2 columns. In column 1 I have numbers in it, which can also repeat:
23 true
62 false
55 true
23 true
23 false
42 false
...

In column 2, a true or false value is stored for each number.

What is the code for the new column if I add up all the same numbers in column 1 and then want to check that if only one of the group of numbers added up is false, they are all false in the group of numbers?

It should look like this:

Column 1 / Column 2 / New column
23 true false
62 false false
55 true true
23 true false
23 false false
42 false false
52 true true
6 true true
...

I am grateful for any help!

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

Hi @Dominik-1988 ,

 

Please follow these steps:

  1.        Number of groupings Number of rows

vyifanwmsft_0-1700715821512.png

Column =

CALCULATE (

    COUNT ( 'Table'[number] ),

    FILTER ( 'Table', 'Table'[number] = EARLIER ( 'Table'[number] ) )

)

 

  1.        Output blank when equal to 1, output ”t or f” when greater than 1

vyifanwmsft_1-1700715821513.png

Column 2 =

VAR _1 =

    IF ( 'Table'[Column] > 1, 'Table'[t or f], BLANK () )

RETURN

    MAXX ( FILTER ( 'Table', 'Table'[number] = EARLIER ( 'Table'[number] ) ), _1 )
  1.        When the values are the same, if there is a false, output false.

vyifanwmsft_2-1700715895299.png

result =

VAR _1 =

    MINX (

        FILTER ( 'Table', 'Table'[number] = EARLIER ( 'Table'[number] ) ),

        'Table'[Column 2]

    )

RETURN

    IF ( 'Table'[Column] = 1, 'Table'[t or f], _1 )

 

  1. final output

vyifanwmsft_3-1700715895301.png

 

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Yifan Wang

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

1 REPLY 1
v-yifanw-msft
Community Support
Community Support

Hi @Dominik-1988 ,

 

Please follow these steps:

  1.        Number of groupings Number of rows

vyifanwmsft_0-1700715821512.png

Column =

CALCULATE (

    COUNT ( 'Table'[number] ),

    FILTER ( 'Table', 'Table'[number] = EARLIER ( 'Table'[number] ) )

)

 

  1.        Output blank when equal to 1, output ”t or f” when greater than 1

vyifanwmsft_1-1700715821513.png

Column 2 =

VAR _1 =

    IF ( 'Table'[Column] > 1, 'Table'[t or f], BLANK () )

RETURN

    MAXX ( FILTER ( 'Table', 'Table'[number] = EARLIER ( 'Table'[number] ) ), _1 )
  1.        When the values are the same, if there is a false, output false.

vyifanwmsft_2-1700715895299.png

result =

VAR _1 =

    MINX (

        FILTER ( 'Table', 'Table'[number] = EARLIER ( 'Table'[number] ) ),

        'Table'[Column 2]

    )

RETURN

    IF ( 'Table'[Column] = 1, 'Table'[t or f], _1 )

 

  1. final output

vyifanwmsft_3-1700715895301.png

 

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Yifan Wang

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

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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