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
Fraz707
Helper I
Helper I

Sending E-mail report for only the top 10 entries from a report

Hi,

I've made a report which contains data of various users about and the Sql queries they executed, it has various columns like username, query, start time, end time, execution etc., now what I want to do is have a email sent out to me everyday based on the execution time which should contain all the columns for only the top 10 entries of each user rather than the whole report.

 

Is there any way to do this? An early reply would be appreciated as this is kind of urgent.

 

Thank you!

 

@Power bi

@developer 

1 ACCEPTED SOLUTION

Hi @Fraz707 ,

 

Would you please add the filter in summarize:

 

 

Measure =
VAR a =
    TOPN (
        3,
        SUMMARIZE (
            FILTER ( ALL ( 'Table' ), DAY ( 'Table'[TimeGenerated] ) = DAY ( TODAY () ) ),
            'Table'[executiontime]
        ),
        'Table'[executiontime], 0
    )
RETURN
    IF (
        MAX ( 'Table'[executiontime] ) IN DISTINCT ( a ),
        MAX ( 'Table'[executiontime] ),
        BLANK ()
    )

 

 

Best Regards,

Dedmon Dai

View solution in original post

3 REPLIES 3
v-deddai1-msft
Community Support
Community Support

Hi @Fraz707 ,

 

Would you please use the TOPN function to select the data you want :

 

Measure =

VAR a =

    TOPN ( 3, SUMMARIZE ( ALL ( 'Table' ), 'Table'[executiontime] ), 'Table'[executiontime], 0 )

RETURN

    IF (

        MAX ( 'Table'[executiontime] ) IN DISTINCT ( a ),

        MAX ( 'Table'[executiontime] ),

        BLANK ()

    )

 

Since report subscription does not retain filter in email image , so if you need a picture in the email to show the query for the top10  execution time , you should use the measure instead of filter directly on the visual.

 

Then try to subscribe yourself to the report: https://docs.microsoft.com/en-us/power-bi/service-report-subscribe.

 

Please also refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EfV3b7LkpCpIjpTjma...

 

Best Regards,

Dedmon Dai

Hi @v-deddai1-msft  thanks for the reply, your solution really helped but I wanted that the report should be generated everyday based on the execution time for the current day only rather than considering the execution time for the whole time span, for this I used LASTDATE(table[TimeGenerated]) at the end of the measure instead of BLANK() but its giving error "Result: MdxScript(Model) (1, 46) Calculation error in measure 'ExampleTable'[Measure]: A date column containing duplicate dates was specified in the call to function 'LASTDATE'. This is not supported"

 

Can you tell me what else I can use Instead of LASTDATE to get the desired output?

 

Thanks.

Hi @Fraz707 ,

 

Would you please add the filter in summarize:

 

 

Measure =
VAR a =
    TOPN (
        3,
        SUMMARIZE (
            FILTER ( ALL ( 'Table' ), DAY ( 'Table'[TimeGenerated] ) = DAY ( TODAY () ) ),
            'Table'[executiontime]
        ),
        'Table'[executiontime], 0
    )
RETURN
    IF (
        MAX ( 'Table'[executiontime] ) IN DISTINCT ( a ),
        MAX ( 'Table'[executiontime] ),
        BLANK ()
    )

 

 

Best Regards,

Dedmon Dai

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.