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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Bokazoit
Post Patron
Post Patron

How to count amount of occurences

I have multiple answers (HeartId) pr. user (ResponderId). We wants to know and display how many ResponderIds that have more than one HeartId:

Bokazoit_0-1672645347172.png

Then we would like to group and display how many got only 1 heart disease, 2 heart diseases etc.

Bokazoit_1-1672645436966.png

Can that be done?

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

Hi @Bokazoit ,

 

I suggest you to select [Id] column and then unpivot other columns in Power Query Editor.

New table should look like as below.

RicoZhou_0-1672732336407.png

Then create a count table.

Count = GENERATESERIES(1, 5, 1)

Measure:

Count ID = 
VAR _SUMMARIZE = SUMMARIZE('Table','Table'[Id],"Sum",CALCULATE(SUM('Table'[Value])))
RETURN
COUNTAX(FILTER(_SUMMARIZE,[Sum] = SUM('Count'[Count])),[Id])

Result is as below.

RicoZhou_1-1672732653391.png

 

Best Regards,
Rico Zhou

 

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

4 REPLIES 4
v-rzhou-msft
Community Support
Community Support

Hi @Bokazoit ,

 

I suggest you to select [Id] column and then unpivot other columns in Power Query Editor.

New table should look like as below.

RicoZhou_0-1672732336407.png

Then create a count table.

Count = GENERATESERIES(1, 5, 1)

Measure:

Count ID = 
VAR _SUMMARIZE = SUMMARIZE('Table','Table'[Id],"Sum",CALCULATE(SUM('Table'[Value])))
RETURN
COUNTAX(FILTER(_SUMMARIZE,[Sum] = SUM('Count'[Count])),[Id])

Result is as below.

RicoZhou_1-1672732653391.png

 

Best Regards,
Rico Zhou

 

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

 

Thanks! that did the trick. Only needed to alter a few things 😉

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely. As a Super User you can attach the data right here.

I have added a simple view of sample data and the desired result:

 

Bokazoit_0-1672732710648.png

ResponderId comes from my Fact and the type of Heart disease come from my DimHeartdisease. The third table is constructed for the purpose of showing the endresult.

The first table shows the data from the Fact and Dimension table. The easy part is to count the number of diseases pr. ResponderId (second table) . The hard part for me is to place each count in a table or Chart:

 

ResponderId 1001550 has 5 diseases and therefor it counts to 1 in the third table on first row with the number marked 5. ResponderId 1001557 has 3 diseases and therefor it counts to 1 in the third table on third row with the number marked 3.

The rest ReponderIds has 1 disease and that amounts to 8 placed in the fifth row with the number marked 1.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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