cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
kreneec
Frequent Visitor

Loop Through Columns To Create a Set

Hello there!

 

I have five columns with the following data:

BaltimoreCincinnatiClevelandPittsburghAFCNorth
748362712

 

My requirement is:  if each column  has a number > 0, then make a set that equals '1'.  So, my output would look like this:

BaltimoreCincinnatiClevelandPittsburghAFCNorth# of Sets
7483627122

 

How do I do this in Power BI using either a measure or column?

 

Thanks in advance 

4 REPLIES 4
kreneec
Frequent Visitor

Re: Loop Through Columns To Create a Set

Oh, I should mention this would be based on a unique id.  So, I've updated the columns:

 

What it looks like now:

IDBaltimoreCincinnatiClevelandPittsburghAFCNorth
174836271

2

 

What I would like for it to look like:

IDBaltimoreCincinnatiClevelandPittsburghAFCNorth# of Sets
17483627122
Microsoft v-jayw-msft
Microsoft

Re: Loop Through Columns To Create a Set

hi @kreneec ,

 

If I understand you correctly, # of sets is the sum of set, so I’m confused about why # of sets is 2 in your table.

Please check following steps if it could solve your problem:

1. Unpivot table by columns except ID.

2. Create measure:

    # of sets = CALCULATE(COUNT('Table'[Value]),FILTER('Table','Table'[Value]>0))

3. Create matrix visual and result would be shown as below:1.PNG

Otherwise, please help me understand why # of sets is 2.

BTW, Pbix as attached, hopefully works for you.

 

Best Regards,

Jay

 

Community Support Team _ Jay Wang

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

kreneec
Frequent Visitor

Re: Loop Through Columns To Create a Set

Hi Jay.

 

Thank you for responding.  The number of sets is defined as "each column has to have greater than or equal to a 1 to define a set."  So, as example:

Baltimore = 74; true;

Cincinnati = 83; true;

Cleveland = 62; true;

Pittsburgh = 71; true;

AFCNorth = 2; true

 

Since every column has more than 1, a set has been completed, i.e. add '1' to the # of sets column.  Now, I need to reiterate again to check to see if another set has been completed.  It has, which means add another '1' to the # of sets column, which means there are only 2 completed sets.  Hope that makes sense.

Microsoft v-jayw-msft
Microsoft

Re: Loop Through Columns To Create a Set

Hi @kreneec ,

 

Thank you for your patient explanation. Please check following steps as blew and see if the result meet your expectations:

1. Create calculated column:

    set = IF('Table'[Pittsburgh]*'Table'[Cincinnati]*'Table'[Cleveland]*'Table'[Baltimore]*'Table'[AFCNorth]>0,1,0)

2. Create Measure:

    # of sets = CALCULATE(SUM('Table'[set]),FILTER(ALLSELECTED('Table'),'Table'[ID]<=MAX('Table'[ID])))

3. Result would be shown as below:

1.PNG

Pbix as attached.

 

Best Regards,

Jay

 

Community Support Team _ Jay 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
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors