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
apoje
Helper II
Helper II

Calculated Column based on Date Period selected in a Slicer

Hi, 

 

I am new to the calculated fields in BI. I created a dashboard, where I can see the product sales based on a date selection in a slicer. The date selection is periodical. 

 

I would like to know how much of a certain unit is sold per day. So if I select a range in a slicer this needs to calculate the sales number that was returned from selection divided by number of days. 

 

powerBI_forum.png 

How can I achieve this result? 

 

Thank you! 

Andraz

1 ACCEPTED SOLUTION

Hi @apoje ,

 

Sorry for misunderstanding your request. please updated the measure as below.

 

average per day =
VAR k =
    CALENDAR (
        CALCULATE (
            MIN ( 'py-sales-data-raw'[OrderDate.date] ),
            ALLSELECTED ( 'py-sales-data-raw' )
        ),
        CALCULATE (
            MAX ( 'py-sales-data-raw'[OrderDate.date] ),
            ALLSELECTED ( 'py-sales-data-raw' )
        )
    )
RETURN
    DIVIDE ( SUM ( 'py-sales-data-raw'[OrderItem.quantity] ), COUNTROWS ( k ) )

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

4 REPLIES 4
v-frfei-msft
Community Support
Community Support

Hi @apoje ,

 

To create a measure as below.

 

average per day = 
DIVIDE ( SUM ( 'Table'[sales] ), DISTINCTCOUNT ( 'Table'[date] ) )

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi @v-frfei-msft

 

I have used the formula that you have suggested, but I do not recieve a desired output.

 

Average_per_Day = DIVIDE(SUM('py-sales-data-raw'[OrderItem.quantity]), DISTINCTCOUNT('py-sales-data-raw'[OrderDate.date]))

Please check the output:

powerBI_forum_1.png

 

I set the date for the full April and I recieve an average per day for the first product od 1.04 per day, where the monthly sales were 650. So the result should be 22 per day. 

 

Do you see where I did a mistake and/or what do I need to adjust?

 

Thanks for the help!

Andraz 

 

 

Hi @apoje ,

 

Sorry for misunderstanding your request. please updated the measure as below.

 

average per day =
VAR k =
    CALENDAR (
        CALCULATE (
            MIN ( 'py-sales-data-raw'[OrderDate.date] ),
            ALLSELECTED ( 'py-sales-data-raw' )
        ),
        CALCULATE (
            MAX ( 'py-sales-data-raw'[OrderDate.date] ),
            ALLSELECTED ( 'py-sales-data-raw' )
        )
    )
RETURN
    DIVIDE ( SUM ( 'py-sales-data-raw'[OrderItem.quantity] ), COUNTROWS ( k ) )

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Thanks @v-frfei-msft !

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors