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

Max value an Max value count

Hello,

 

I need to create measures to pull the "Occupied Machines Max Value" , "Max Value repeat frequency", "Occupied Machines Second largest Value" based on "Game name" and "Game Version" . 

I need to pull the data as per the summary table from the raw data table using dax measures. Does anyone know how to attched a spreasheet as it has over 1000 rows which I can' paste on the body. I just included few rows from raw data as a sample

 

any help is greatly appreciated.

 

Thanks,

Deevs

Summary

Game NameGame VersionOccupied Machines Max  ValueMax Value repeat frequencyOccupied Machines Second largest   Value
A32271
A51450
B101370
C5746
C101530
F11061105
F526124

 

Raw Data (Sample )

DateDay_NameHour_DescriptionGame NameGame VersionActive MachinesOccupied Machines
17-Aug-20Mon06:00:00 to 06:59:59A510
17-Aug-20Mon07:00:00 to 07:59:59A510
17-Aug-20Mon08:00:00 to 08:59:59A510
17-Aug-20Mon10:00:00 to 10:59:59A510
17-Aug-20Mon02:00:00 to 02:59:59A510
17-Aug-20Mon03:00:00 to 03:59:59A510
17-Aug-20Mon04:00:00 to 04:59:59A510
17-Aug-20Mon05:00:00 to 05:59:59A510
18-Aug-20Tue06:00:00 to 06:59:59A510
18-Aug-20Tue07:00:00 to 07:59:59A510
18-Aug-20Tue08:00:00 to 08:59:59A510
18-Aug-20Tue09:00:00 to 09:59:59A510
18-Aug-20Tue22:00:00 to 22:59:59A510
18-Aug-20Tue00:00:00 to 00:59:59A510
18-Aug-20Tue01:00:00 to 01:59:59A510
18-Aug-20Tue03:00:00 to 03:59:59A510
18-Aug-20Tue04:00:00 to 04:59:59A510
18-Aug-20Tue05:00:00 to 05:59:59A510
19-Aug-20Wed06:00:00 to 06:59:59A510
19-Aug-20Wed05:00:00 to 05:59:59A510
20-Aug-20Thu06:00:00 to 06:59:59A510
20-Aug-20Thu07:00:00 to 07:59:59A510
20-Aug-20Thu08:00:00 to 08:59:59A510
20-Aug-20Thu09:00:00 to 09:59:59A510
20-Aug-20Thu03:00:00 to 03:59:59A510
20-Aug-20Thu04:00:00 to 04:59:59A510
21-Aug-20Fri07:00:00 to 07:59:59A510
21-Aug-20Fri09:00:00 to 09:59:59A510
21-Aug-20Fri10:00:00 to 10:59:59A510
21-Aug-20Fri03:00:00 to 03:59:59A510
21-Aug-20Fri04:00:00 to 04:59:59A510
22-Aug-20Sat10:00:00 to 10:59:59A510
22-Aug-20Sat04:00:00 to 04:59:59A510
23-Aug-20Sun07:00:00 to 07:59:59A510
23-Aug-20Sun08:00:00 to 08:59:59A510
23-Aug-20Sun10:00:00 to 10:59:59A510
23-Aug-20Sun23:00:00 to 23:59:59A510
23-Aug-20Sun01:00:00 to 01:59:59A510
23-Aug-20Sun04:00:00 to 04:59:59A510
1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi , @Anonymous 

According to @amitchandak  tips, I made a demo for your reference

It should be noted that there are some minor errors in  amitchandak's  formula.

Part of formula

 

 

var _max = calculate(table[Occupied Machines], allexcept(Table,Table[Game Name],[Game Version]))

 

 

should be modified as  below:

 

 

var _max=CALCULATE(MAX('Table'[Occupied Machines]),ALLEXCEPT('Table','Table'[Game Name],'Table'[Game Version]))

 

 

The result will show as below:

3.png

 

If your problem has been solved,  please add your reply  or  accept helpful reply above as solution to close this thread.So that others having similar concern can find the answer more easily.  If you haven't, please feel free to ask.

 

Best Regards,
Community Support Team _ Eason

View solution in original post

3 REPLIES 3
v-easonf-msft
Community Support
Community Support

Hi , @Anonymous 

According to @amitchandak  tips, I made a demo for your reference

It should be noted that there are some minor errors in  amitchandak's  formula.

Part of formula

 

 

var _max = calculate(table[Occupied Machines], allexcept(Table,Table[Game Name],[Game Version]))

 

 

should be modified as  below:

 

 

var _max=CALCULATE(MAX('Table'[Occupied Machines]),ALLEXCEPT('Table','Table'[Game Name],'Table'[Game Version]))

 

 

The result will show as below:

3.png

 

If your problem has been solved,  please add your reply  or  accept helpful reply above as solution to close this thread.So that others having similar concern can find the answer more easily.  If you haven't, please feel free to ask.

 

Best Regards,
Community Support Team _ Eason

Anonymous
Not applicable

Hi @v-easonf-msft 

Really appreciate your help on this and it worked perfectly :). Since I couldn’t get the measure to work with the earlier solution posted by amit I came up with my own solution.

 

Not sure it the best way but here we go. Let me know what you think. Also can you let me know how to attached a spreadsheet/pbix file as initially I wanted to attached the data sample in a spreadsheet or in a pbix file.

 

Second Largest Value =

CALCULATE (

    MAX ('Table'[Occupied Machines]),

    FILTER (

        'Table',

        'Table'[Occupied Machines]

            < MAX ('Table'[Occupied Machines])

    )

)

 

 

Third Largest Value =

CALCULATE (

    MAX ( 'Table'[Occupied EGMs] ),

    FILTER (

        'Table',

        'Table'[Occupied EGMs]

            < CALCULATE (

                MAX ( 'Table'[Occupied EGMs] ),

                FILTER (

                    'Table',

                    'Table'[Occupied EGMs]

                        < MAX ( 'Table'[Occupied Machines] )

                )

            )

    )

)

 

 

amitchandak
Super User
Super User

@Anonymous , you should able get max and second max like this

max(table[Occupied Machines])

second best =
var _max = calculate(table[Occupied Machines], allexcept(Table,Table[Game Name],[Game Version]))
return
calculate(max(table[Occupied Machines]), filter(table,table[Occupied Machines]<_max))

 

best count =
var _max = calculate(table[Occupied Machines], allexcept(Table,Table[Game Name],[Game Version]))
return
calculate(count(table[Occupied Machines]), filter(table,table[Occupied Machines]=_max))

 

 

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.