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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
tqn626
Frequent Visitor

Average of Distinctcount over time

I have this code that shows me the disctinctcount of stores with any sales. I'm using this in a calendar visual. How would I get the average distinct count at each calendar category. In the visual on the bottom i want the monthly to show 19 stores instead of 39.

 

 

Stores =
CALCULATE (
    DISTINCTCOUNT ( DimStore_List[Store] ),
    FILTER ( 'Daily Data', 'Daily Data'[Net_Sales] > 0 )
)

 

 

Stores.PNG

1 ACCEPTED SOLUTION

Hi @tqn626 ,

 

You can try the following measure:

 

Stores =
IF (
    ISINSCOPE ( the_hierarchy_in_fw_quarater ),
    CALCULATE (
        DISTINCTCOUNT ( DimStore_List[Store] ),
        FILTER ( 'Daily Data', 'Daily Data'[Net_Sales] > 0 )
    ),
    AVERAGEX (
        DimStore_List,
        CALCULATE (
            DISTINCTCOUNT ( DimStore_List[Store] ),
            FILTER ( 'Daily Data', 'Daily Data'[Net_Sales] > 0 )
        )
    )
)

 

If you need accurate formula, please show us sample data.

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@tqn626 , Based on the group level of Day or month then create a measure like

 

Stores =
var _1 =
CALCULATE (
DISTINCTCOUNT ( DimStore_List[Store] ),
FILTER ( 'Daily Data', 'Daily Data'[Net_Sales] > 0 )
)
return
sumx(values(Date[Date]),_1)

Hmm, This didn't work, I got a much larger number.

Hi @tqn626 ,

 

You can try the following measure:

 

Stores =
IF (
    ISINSCOPE ( the_hierarchy_in_fw_quarater ),
    CALCULATE (
        DISTINCTCOUNT ( DimStore_List[Store] ),
        FILTER ( 'Daily Data', 'Daily Data'[Net_Sales] > 0 )
    ),
    AVERAGEX (
        DimStore_List,
        CALCULATE (
            DISTINCTCOUNT ( DimStore_List[Store] ),
            FILTER ( 'Daily Data', 'Daily Data'[Net_Sales] > 0 )
        )
    )
)

 

If you need accurate formula, please show us sample data.

 

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

 

Best Regards,

Dedmon Dai

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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