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
nagoor
Helper III
Helper III

Finding Max of 3 values in a day for different product sales

Hi Experts, 

 

Could you help me on the below topic, 

I Have a data where it has hour lvl sales amount per sector, i want to identify the Top 3 sales period and amount of sales in average. 

 

Example with my data attached: 

 

Combine_1 (ending) 

Take Top 3 hours

Average of Top 3 hours values 

https://www.dropbox.com/scl/fi/mdyyfpkkowgvz8ohngi5q/Raw.xlsx?dl=0&rlkey=s7bjafjh4f2h0wg9g4hxdgffp 

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

Hi @nagoor ,

 

We can use the following measue in visual filter to show the top 3 hour (set "is 1" in visual filter)

 

IS TOP 3 Hour = 
IF (
    RANKX (
        CALCULATETABLE (
            DISTINCT ( 'Table'[Time] ),
            ALLSELECTED (),
            'Table'[Date] IN DISTINCT ( 'Table'[Date] ),
            'Table'[Product] IN DISTINCT ( 'Table'[Product] )
        ),
        CALCULATE ( SUM ( 'Table'[Total Sales] ) ),
        ,
        DESC,
        DENSE
    ) <= 3,
    1,
    -1
)

 

Date column was created by following calculated column formula:

 

Date = INT([Time])

 

Then we can Create following measure to calculate average sales based on the date and product (do not need above measure  in visual filter)

 

Average = AVERAGEX(TOPN(3,SUMMARIZE('Table','Table'[Time],"AllSales",SUM('Table'[Total Sales])),[AllSales],DESC),[AllSales])

 

10.jpg

 

 


If it doesn't meet your requirement, Could you please show the exact expected result based on the tables that you have shared?


By the way, PBIX file as attached.


Best regards,

 

Community Support Team _ Dong Li
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

2 REPLIES 2
v-lid-msft
Community Support
Community Support

Hi @nagoor ,

 

We can use the following measue in visual filter to show the top 3 hour (set "is 1" in visual filter)

 

IS TOP 3 Hour = 
IF (
    RANKX (
        CALCULATETABLE (
            DISTINCT ( 'Table'[Time] ),
            ALLSELECTED (),
            'Table'[Date] IN DISTINCT ( 'Table'[Date] ),
            'Table'[Product] IN DISTINCT ( 'Table'[Product] )
        ),
        CALCULATE ( SUM ( 'Table'[Total Sales] ) ),
        ,
        DESC,
        DENSE
    ) <= 3,
    1,
    -1
)

 

Date column was created by following calculated column formula:

 

Date = INT([Time])

 

Then we can Create following measure to calculate average sales based on the date and product (do not need above measure  in visual filter)

 

Average = AVERAGEX(TOPN(3,SUMMARIZE('Table','Table'[Time],"AllSales",SUM('Table'[Total Sales])),[AllSales],DESC),[AllSales])

 

10.jpg

 

 


If it doesn't meet your requirement, Could you please show the exact expected result based on the tables that you have shared?


By the way, PBIX file as attached.


Best regards,

 

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

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.