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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Julie_
Frequent Visitor

Filter a Distinctcount function by another measure

Hello,

 

i need a measure that calculated the distinct count of Items, but only for the months January and December. So it should just distinct count the items where the Measure i already wrote is not blank

The measure to sum the quantity of Jan&Dec 

 

VAR SumofQuantity_Jan_Dec =
IF(
    SELECTEDVALUE(v_DimCountrySoldTo[CountryEN]) = "Austria",
    CALCULATE(
        [GlobalDeliveredQuantity new],
        v_DimDate[MonthNumber] in {1,2,12}
    ),
    CALCULATE(
        [GlobalDeliveredQuantity new],
        v_DimDate[MonthNumber] in {1,12}
    )
)
 
Help please!
1 ACCEPTED SOLUTION

Distinct count Jan Dec =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Column] ),
    FILTER ( VALUES ( 'Table'[Column] ), NOT ISBLANK ( [My Measure] ) )
)

If column is enough to correctly identify the row and produce the value for the measure then this should work. If additional columns are needed in the filter context then you can replace VALUES with a SUMMARIZE statement including all necessary rows.

View solution in original post

3 REPLIES 3
johnt75
Super User
Super User

Try

Distinct count Jan Dec =
IF (
    SELECTEDVALUE ( v_DimCountrySoldTo[CountryEN] ) = "Austria",
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Column] ),
        v_DimDate[MonthNumber] IN { 1, 2, 12 }
    ),
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Column] ),
        v_DimDate[MonthNumber] IN { 1, 12 }
    )
)

this doesn´t work because the item Table is not connected to the Date table, i need to filter it by the measure but i don´t know how

 

Distinct count Jan Dec =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Column] ),
    FILTER ( VALUES ( 'Table'[Column] ), NOT ISBLANK ( [My Measure] ) )
)

If column is enough to correctly identify the row and produce the value for the measure then this should work. If additional columns are needed in the filter context then you can replace VALUES with a SUMMARIZE statement including all necessary rows.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.