Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
How can I achieve this result?
Thank you!
Andraz
Solved! Go to 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 ) )
Hi @apoje ,
To create a measure as below.
average per day = DIVIDE ( SUM ( 'Table'[sales] ), DISTINCTCOUNT ( 'Table'[date] ) )
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:
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 ) )
User | Count |
---|---|
76 | |
75 | |
46 | |
31 | |
28 |
User | Count |
---|---|
99 | |
91 | |
51 | |
49 | |
46 |