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
NBOnecall
Helper V
Helper V

Average based on date slicer from DImtime table

Hi,

 

I have been searching this forum and couldn't find anything relating to my question. Hoping someone can help me out.

 

I have a table called InventorySnapshot and want to create a measure that finds the average of the column value seen below based on the date range slicer. The date range slicer has a relationship between the inventory date and a calender date.

 

InventorySnaphot1.JPG

 

My expected results would be the following;

 

Date slicer: Jan 31st - Feb 1st, $0 (Jan 31st Value) + $1,137.40 (Feb 1st Value)/2(days) = 568.70

Date Slicer: Jan 31st - Feb 3rd, ($0 + $1,137.40 + $1,137.40 + $1,137.40)/4 = 853.05

 

Date Slicer: Feb 1st - Feb 3rd, ($1,137.40 + $1,137.40 + $1,137.40)/3 = 1,137.40

 

As you can see January 31st is not in the data set, but because of the datedim table, I would still be able to use the slicer to get that date, I just want the value to be 0.

 

Thanks,

Noel

1 ACCEPTED SOLUTION

I think I got this solved. I don't know if it is the perfect way, but at least from my checking it seems to work.

True Average = sum('ns InventorySnapshot'[Value])/[Days]
Days = 
VAR a =
    FIRSTDATE ( Dimtime[Date] )
VAR b =
    CALCULATE ( MAX ( Dimtime[Date] ), ALLSELECTED ( Dimtime[Date] ) )
RETURN
    DATEDIFF ( a, b, DAY )+1

I would think there would be a better way, but I don't know.

View solution in original post

3 REPLIES 3
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @NBOnecall 

Could you share a simplified sample file here to reproduce your scenario?You can upload the .pbix file to OneDrive and post the link here. Do mask sensitive data before uploading.Please explain more about your assumed sample data and expected output.

How to Get Your Question Answered Quickly

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I think I got this solved. I don't know if it is the perfect way, but at least from my checking it seems to work.

True Average = sum('ns InventorySnapshot'[Value])/[Days]
Days = 
VAR a =
    FIRSTDATE ( Dimtime[Date] )
VAR b =
    CALCULATE ( MAX ( Dimtime[Date] ), ALLSELECTED ( Dimtime[Date] ) )
RETURN
    DATEDIFF ( a, b, DAY )+1

I would think there would be a better way, but I don't know.

Hi @NBOnecall 

Glad to hear you've solved it, please accept your reply as solution, that way, other community members will easily find the solution when they get same issue.

Regards,

 

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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