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
SunilRaj
Frequent Visitor

Rolling Average

Dynamic Date in select statement creating issue for Power BI Report

 

SELECTCOUNT(*),ABS(AVG(TO_DATE(ENTERED_DATE)-TO_DATE(:P_DATE_FROM)))/30 AVG_AGE_OF_ACCOUNT,ASSESS.TAX_TYPE_NO TAX_TYPE_NO, TTY.TAX_TYPE_DESC
FROMOBJECTION OBJ,ASSESSMENT ASSESS ,TAX_TYPE TTY
WHERE OBJ.ENTERED_DATE <:P_DATE_FROM
AND OBJ.CLOSED_DATE ISNULL
AND ASSESS.ASSESS_NO = OBJ.ASSESS_NO
AND ASSESS.TAX_TYPE_NO = TTY.TAX_TYPE_NO
AND OBJ.TAX_CENTRE_NO=:P_TAX_CENTRE_NO
GROUPBY ASSESS.TAX_TYPE_NO , TTY.TAX_TYPE_DESC

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @SunilRaj ,

I created some data:

vyangliumsft_0-1657250653446.png

Here are the steps you can follow:

1. Create calculated column.

Year = YEAR('Table'[Date])

2. Create measure.

Measure =
var _select=SELECTEDVALUE('Table'[Date])
return
AVERAGEX(
    FILTER(
        SUMMARIZE(ALL('Table'),
        'Table'[Date],'Table'[Month],
        "Avg value",AVERAGE('Table'[amount])),
        'Table'[Date]<=_select&&'Table'[Month]=MAX('Table'[Month])),
        [Avg value])

3. Result:

vyangliumsft_1-1657250653449.png

If you need pbix, please click here.

If I have misunderstood your meaning, please provide your desired output and your pbix without privacy information.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @SunilRaj ,

I created some data:

vyangliumsft_0-1657250653446.png

Here are the steps you can follow:

1. Create calculated column.

Year = YEAR('Table'[Date])

2. Create measure.

Measure =
var _select=SELECTEDVALUE('Table'[Date])
return
AVERAGEX(
    FILTER(
        SUMMARIZE(ALL('Table'),
        'Table'[Date],'Table'[Month],
        "Avg value",AVERAGE('Table'[amount])),
        'Table'[Date]<=_select&&'Table'[Month]=MAX('Table'[Month])),
        [Avg value])

3. Result:

vyangliumsft_1-1657250653449.png

If you need pbix, please click here.

If I have misunderstood your meaning, please provide your desired output and your pbix without privacy information.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

amitchandak
Super User
Super User

@SunilRaj , You need a measure like

averageX(filter(OBJECTION , not(isblank(OBJECTION [CLOSED_DATE])) ), datediff(OBJECTION[ENTERED_DATE], OBJECTION[P_DATE_FROM] , day))

 

or

 

sumx(filter(OBJECTION , not(isblank(OBJECTION [CLOSED_DATE])) ), datediff(OBJECTION[ENTERED_DATE], OBJECTION[P_DATE_FROM] , day))/30

 

other filter can be selected from slicer or you add filter

Hi @amitchandak 
I want to find dynamic average pending month in power bi report objection cases.
e.g - one objection case enter in 11th June 2013 and still open.
when I selected July 2013 then average pending month output will 0.67 and when I am select august 2013 then o/p will 1.7 and increasing as so on till date.
If any idea regarding this pls suggest.

Thanks

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.

Top Solution Authors