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
Back2Basics
Helper IV
Helper IV

Calculate countif based on another table

Hi

 

I have an excel table with a column for 'outcomes'. Users are able to add several outcomes, separated by commas. 

I have created a table in PBI which is just the possible 'outcomes' from the file.

 

I'm trying to find a way to count how many rows contain each of the 'outcomes'. So if the column had 5 outcomes, separated by columns, there would be a count of 1 for each of the 5 relevant outcomes. 

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @Back2Basics,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or accept the helpful suggestions to help others who faced similar requirements to find it more quickly.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Ashish_Mathur
Super User
Super User

Hi,

In the Query Editor, you should split the outcome by rows to allow each outcome to appear in its own cell.  Now create your desired visual.  You may need to write a DISTINCTCOUNT() measure.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-shex-msft
Community Support
Community Support

Hi @Back2Basics,

Perhaps you can try to use the following formula to expand these values, then you can use countrows function to get the item count in your field:

Column item Count=
VAR _path =
    SUBSTITUTE (
        CONCATENATEX ( VALUES ( 'Table'[Column] ), [Column], "," ),
        ",",
        "|"
    )
VAR _length =
    PATHLENGTH ( _path )
VAR _pathtable =
    ADDCOLUMNS (
        GENERATESERIES ( 1, _length, 1 ),
        "Column", PATHITEM ( _path, [Value] )
    )
RETURN
    COUNTROWS ( _pathtable )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Greg_Deckler
Super User
Super User

@Back2Basics I've generally done it this way:

New Column = LEN('Table'[Column]) - LEN(SUBSTITUTE('Table'[Column],",","")) + 1

Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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