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

Dynamic Date in select statement to Power BI Report Creation

Hello ,

Please help as we are trying to create Power BI Report using oracl query.But the bold part is creating issue

 

SELECT COUNT(*),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
GROU PBY ASSESS.TAX_TYPE_NO , TTY.TAX_TYPE_DESC

1 ACCEPTED SOLUTION

Hi @SunilRaj ,

 

Do you want to calculate the average of all [ASSESS_NO]?

 

Avg_diff = AVERAGEX ( VALUES ( OBJECTION[ASSESS_NO] ), [M_DateDiff] )

vkkfmsft_0-1658477137278.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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

9 REPLIES 9
v-kkf-msft
Community Support
Community Support

Hi @SunilRaj ,

 

Has your problem been solved? If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.


Best Regards,
Winniz

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. and  still case open so average pending month output for this month will  99.68.

Thanks

Hi @SunilRaj ,

 

I am not sure if I understood your question correctly. I created these example tables and data.

 

ASSESSMENT:

vkkfmsft_0-1657872905963.png

OBJECTION:

vkkfmsft_1-1657872933817.png

TAX_TYPE:

vkkfmsft_2-1657872983473.png

Two parameters:

vkkfmsft_3-1657873004004.png

 

Then I add a custom column in OBJECTION table.

 

 

= if [CLOSED_DATE] = null and [ENTERED_DATE] < Date.FromText(P_DATE_FROM) and [TAX_CENTRE_NO] = P_TAX_CENTRE_NO then Duration.Days([ENTERED_DATE] - Date.FromText(P_DATE_FROM)) else null

 

vkkfmsft_4-1657873022403.png

 

Then create the relationship and measure.

 

vkkfmsft_6-1657873870277.png

 

Measure = ABS ( AVERAGE ( OBJECTION[Diff] ) ) / 30

 

vkkfmsft_5-1657873680987.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 I want to find dynamic average pending month as like this given below.

 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. and  still case open so average pending month output for this month will  99.68.Screenshot_2.png

 

image_2022_07_18T04_39_48_071Z.pngimage_2022_07_18T04_38_43_995Z.pngimage_2022_07_18T04_37_50_793Z.pngimage_2022_07_19T06_05_02_471Z.pngimage_2022_07_19T06_03_30_874Z.pngimage_2022_07_19T06_02_39_267Z.png

Hi @SunilRaj ,

 

Does this meet your desired output?

 

M_DateDiff = 
CALCULATE (
    DATEDIFF ( MAX ( OBJECTION[ENTERED_DATE] ), MIN ( 'Calendar'[Date] ), DAY ) / 30,
    FILTER (
        OBJECTION,
        OBJECTION[ENTERED_DATE] < MIN ( 'Calendar'[Date] )
            && (
                OBJECTION[CLOSED_DATE] > MIN ( 'Calendar'[Date] )
                    || OBJECTION[CLOSED_DATE] = BLANK ()
            )
    )
)

vkkfmsft_0-1658308077517.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hello, your provided solution work for two month i.e july  and Aug then after  average value mismatch.image_2022_07_22T04_36_54_478Z.pngimage_2022_07_22T04_35_29_757Z.pngimage_2022_07_22T04_41_59_125Z.pngimage_2022_07_22T04_40_53_624Z.pngimage_2022_07_22T04_41_17_033Z.png

M_DateDiff = 
CALCULATE (
    DATEDIFF ( MAX ( OBJECTION[ENTERED_DATE] ), MIN ( 'Calendar'[Date] ), DAY ) / 30,
    FILTER (
        OBJECTION,
        OBJECTION[ENTERED_DATE] < MIN ( 'Calendar'[Date] )
            && (
                OBJECTION[CLOSED_DATE] > MIN ( 'Calendar'[Date] )
                    || OBJECTION[CLOSED_DATE] = BLANK ()
            )
    )
)

 

Hi @SunilRaj ,

 

Do you want to calculate the average of all [ASSESS_NO]?

 

Avg_diff = AVERAGEX ( VALUES ( OBJECTION[ASSESS_NO] ), [M_DateDiff] )

vkkfmsft_0-1658477137278.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thanks

v-kkf-msft
Community Support
Community Support

Hi @SunilRaj ,

 

Have you tried importing data by using a native database query? Put your query in the SQL statement box, which appears when you expand the Advanced options section of the Oracle database dialog. Power BI Desktop does not support Oracle native queries that execute a stored procedure.

 

vkkfmsft_1-1657246858069.png

 

Since there is no Oracle database installed, the query I executed with Sql Server is as follows.

 

SELECT  COUNT(*), ABS(AVG( DATEDIFF(dd,convert(DATE,[ENTERED_DATE]),convert(DATE,[:P_DATE_FROM]))))/30 AVG_AGE_OF_ACCOUNT
FROM [CaseTest].[dbo].[Dates_2]

vkkfmsft_0-1657246794181.png


If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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