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
cibgks
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
v-yuezhe-msft
Employee
Employee

@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.

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).

 

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
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.