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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Chris_23
Helper II
Helper II

Distinctcount across 3 levels without countning X and blanks() in the measure

Hello guys,

 

I have a matrix with 3 levels. For the second level, a sum is calculated over the third and second levels if the second Level is "open". Otherwise, there is an 'X'. Now, I want to know for each row how many values from the second level are used to calculate sums, within the respective filter context. In the corresponding example, the value '5' should be assigned for each entry

 

Distinctcount w.o. X.pbix

 

Chris_23_0-1728387279627.png

Any idea how I can get this done? Thank you for your help!

Chris

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the reply from Kedar_Pande.

 

Hi @Chris_23 ,

 

Please try the following dax:

CountNonXValues =
VAR _count =
    CALCULATE (
        DISTINCTCOUNT ( 'Master'[Name] ),
        FILTER (
            ALLSELECTED ( 'Master' ),
            'Master'[Sum] <> "X"
                && 'Master'[Sum] <> BLANK ()
        )
    )
RETURN
    IF (
        ISINSCOPE ( 'Master'[Region] ),
        IF (
            ISINSCOPE ( 'Master'[Region] ) && NOT ( ISINSCOPE ( 'Master'[Name] ) ),
            IF ( 'Master'[Sum] <> "X" && 'Master'[Sum] <> BLANK (), _count, BLANK () ),
            BLANK ()
        ),
        _count
    )

 This is the result:

vlinhuizhmsft_0-1728640126921.png

 

Best Regards,
Zhu
Community Support Team

 

If there is any 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
Anonymous
Not applicable

Thanks for the reply from Kedar_Pande.

 

Hi @Chris_23 ,

 

Please try the following dax:

CountNonXValues =
VAR _count =
    CALCULATE (
        DISTINCTCOUNT ( 'Master'[Name] ),
        FILTER (
            ALLSELECTED ( 'Master' ),
            'Master'[Sum] <> "X"
                && 'Master'[Sum] <> BLANK ()
        )
    )
RETURN
    IF (
        ISINSCOPE ( 'Master'[Region] ),
        IF (
            ISINSCOPE ( 'Master'[Region] ) && NOT ( ISINSCOPE ( 'Master'[Name] ) ),
            IF ( 'Master'[Sum] <> "X" && 'Master'[Sum] <> BLANK (), _count, BLANK () ),
            BLANK ()
        ),
        _count
    )

 This is the result:

vlinhuizhmsft_0-1728640126921.png

 

Best Regards,
Zhu
Community Support Team

 

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

Thanks for your reply. This is absolutely the solution I've looked for.

Chris_23
Helper II
Helper II

No, unfortunately that doesn’t lead to the desired result. In the respective filter context, each row should show 5, as a sum is being calculated over 5 rows.

 

Chris_23_0-1728389860400.png

 

Kedar_Pande
Super User
Super User

Count Open Values = 
VAR OpenValuesCount =
CALCULATE (
COUNTROWS ( 'YourTable' ),
'YourTable'[SecondLevel] = "Open" // Adjust based on your actual column name
)
RETURN
IF ( OpenValuesCount > 0, OpenValuesCount, BLANK() )

If this helped, a Kudos 👍 or Solution mark would be great!
Cheers,
Kedar Pande
www.linkedin.com/in/kedar-pande

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.