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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
hatsjie
Regular Visitor

DAX Distinct Countrows

I have a question regarding the outcome of a query.

DEFINE
MEASURE 'Source'[DistinctCount] = DISTINCTCOUNT('Source'[Source])
MEASURE 'Allocation'[DistinctCountRows] =
    COUNTROWS ( FILTER ( VALUES ( Source[Source] ), COUNT('Allocation'[QUANTITY]) > 0 ) )
MEASURE 'Allocation'[AllocationNew] =   
IF(
    --ISFILTERED('Source'[Source]) && DISTINCTCOUNT('Source'[Source]) > 1
    COUNTROWS ( FILTER ( VALUES ( Source[Source] ), COUNT('Allocation'[QUANTITY])  > 0 ) ) > 1
    ,"N/A (multiple sources selected)"
    ,IF(
        COUNTROWS ( FILTER ( VALUES ( Allocation[LINEPACK_ALLOCATION_TYPE_ID] ), COUNT('Allocation'[QUANTITY]) > 0 ) ) > 1 && NOT ISBLANK('Allocation'[Allocation Count]),
        --DISTINCTCOUNT(Allocation[LINEPACK_ALLOCATION_TYPE_ID]) > 1 && NOT ISBLANK('Allocation'[Allocation Count]),
        "N/A (multiple allocation types selected)",
        SUM('Allocation'[QUANTITY])
   )
)
EVALUATE
SUMMARIZECOLUMNS
(
    Source[Source],
    "Sources", CALCULATE('Source'[DistinctCount])
    ,"Countrows of sources", CALCULATE('Allocation'[DistinctCountRows])
    ,"AllocationNew", CALCULATE('Allocation'[AllocationNew])
)

This results in:

enter image description here

When I put Source in comment the result is:

enter image description here

Though the desired result is [countrows of sources] = 1 and [AllocationNew] should contain a value, because there is only 1 source with a value. I think i'm almost there, but can't figure out what is wrong.

0 REPLIES 0

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.