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

Count several factors of variable without duplicating ID

Hello everyone,

 

I am facing the following problem for a couple of weeks and I couldn't find a solution yet. Any help will be appreciated.

 

To clarify the problem, suppose I have this table:

 

ID                       |           SOURCE

1                        |                s1

2                        |                s2

3                        |              s1,s2

 

I want to show this result in the dashboard

 

SOURCE            |            COUNT

s1                      |                2

s2                      |                2

 

without duplicating the third row of my dataframe.

 

How can I do that?

Thanks in advance

3 REPLIES 3
Highlighted
Microsoft
Microsoft

Re: Count several factors of variable without duplicating ID

@cibgks,

The method that I can think of is to split columns in your table and then create a table visual as shown in the following screenshot.

1.PNG2.PNG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Regular Visitor

Re: Count several factors of variable without duplicating ID

Hi Lydia, thanks for your time and answer.

 

That solution could work, but I should not be duplicating IDs because other variables would be duplicated (for example Amount).

 

Highlighted
Regular Visitor

Re: Count several factors of variable without duplicating ID

I found a way to solve the problem, but it is taking too much time to refresh in a small dataset (60k rows). Any ideas how to optimize this M code?

 

#"test" = Table.AddColumn(#"changed", "counter", (countFunction) =>
List.Sum(Table.TransformRows(#"previoustable", each if Text.Contains(_[source1], countFunction[Source])  then 1 else 0 )))

 

Helpful resources

Announcements

August Community Highlights

Check out a full recap of the month!

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors