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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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