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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
DemingPDCA
Helper II
Helper II

Sum/Count Measure Output

I have created a measure that tells me if a "cell" contains a specific partial text. How can I count/sum that measure?

Ex:
The table looks something like this:

DemingPDCA_0-1671548606777.png

 

And the measure looks for "Direct - " using the following formula:

Count Direct Gross Margin Impact =
CONTAINSSTRING(SELECTEDVALUE('Division Quality Project Tracker'[Gross Margin Impact]), "Direct - ")
 
What I can't seem to figure out is how to get a sum of all the "True" outputs. IN this case - I would want the Total Count = 3

 

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

Hi @DemingPDCA ,

 

You could modify the measure as follows.

 

Count Direct Gross Margin Impact =
COUNTROWS (
    FILTER (
        'Division Quality Project Tracker',
        CONTAINSSTRING (
            'Division Quality Project Tracker'[Gross Margin Impact],
            "Direct - "
        )
    )
) + 0

 

vstephenmsft_0-1671608466399.png

 

You can see that it has a total of 3, and if you want each row to return a total, you can add ALLSELECTED function.

Count Direct Gross Margin Impact =
COUNTROWS (
    FILTER (
        ALLSELECTED ( 'Division Quality Project Tracker' ),
        CONTAINSSTRING (
            'Division Quality Project Tracker'[Gross Margin Impact],
            "Direct - "
        )
    )
) 

vstephenmsft_1-1671608609792.png

 

Best Regards,

Stephen Tao

 

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

2 REPLIES 2
v-stephen-msft
Community Support
Community Support

Hi @DemingPDCA ,

 

You could modify the measure as follows.

 

Count Direct Gross Margin Impact =
COUNTROWS (
    FILTER (
        'Division Quality Project Tracker',
        CONTAINSSTRING (
            'Division Quality Project Tracker'[Gross Margin Impact],
            "Direct - "
        )
    )
) + 0

 

vstephenmsft_0-1671608466399.png

 

You can see that it has a total of 3, and if you want each row to return a total, you can add ALLSELECTED function.

Count Direct Gross Margin Impact =
COUNTROWS (
    FILTER (
        ALLSELECTED ( 'Division Quality Project Tracker' ),
        CONTAINSSTRING (
            'Division Quality Project Tracker'[Gross Margin Impact],
            "Direct - "
        )
    )
) 

vstephenmsft_1-1671608609792.png

 

Best Regards,

Stephen Tao

 

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

Mikelytics
Resident Rockstar
Resident Rockstar

HI @DemingPDCA 

 

Please try the following:

COunt =

SUMX(
   VALUES(Table[Column in your Fact table for granularity definition]),
   var __check = CONTAINSSTRING(SELECTEDVALUE('Division Quality Project Tracker'[Gross Margin Impact]), "Direct - ")
   Return
   IF(__check = TRUE(),1,0)
)

 

Based on your request its hard to say what to put into the VALUES() function. In the end my formula iterates through a list of items which and executes tzhe check. if it is true the the result is 1 else it is 0. In the end all 1 are summed up.

 

Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.