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
Anonymous
Not applicable

DAX: calculate Average from start of the month to current date which is selected from dropdown

Hi All,

 

I have a table wherein we have scrore over all the days, And i have created a datedim table which has date, year, month number and all, If i select a date from dropdown the output should be average scrore from start of that month selected to current date which is selected from drop down. 

 

FYI, The table has many year records from 2017 to 2019. Could you please help me on this.

 

Thanks in Advance:
Nishanth

1 ACCEPTED SOLUTION
yelsherif
Resolver IV
Resolver IV

You can use the date table with a date slicer, so you can select the required date. assuming the date column is 'DateTable'[date], then you can create a separate measure to estimate the month to date value

 

MTDValue =
VAR selectedDate = SELECTEDVALUE('DateTable'[date])

VAR DateStart = DATE(YEAR(selectedDate), MONTH(selectedDate), 1)

 

RETURN

CALCULATE(SUM(myTable[Value]), myTable[date]>=DateStart, myTable[date]<=selectedDate)

View solution in original post

2 REPLIES 2
yelsherif
Resolver IV
Resolver IV

You can use the date table with a date slicer, so you can select the required date. assuming the date column is 'DateTable'[date], then you can create a separate measure to estimate the month to date value

 

MTDValue =
VAR selectedDate = SELECTEDVALUE('DateTable'[date])

VAR DateStart = DATE(YEAR(selectedDate), MONTH(selectedDate), 1)

 

RETURN

CALCULATE(SUM(myTable[Value]), myTable[date]>=DateStart, myTable[date]<=selectedDate)

Sorry, you can use AVERAGE instead of SUM in the last calculation

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.