Forum Discussion

juju's avatar
juju
Icon for Helper III rankHelper III
9 years ago

Calcualting Max hourly value

 

I am looking to create a measure to calculate the max hourly value, for each hour over a 24 hour period, across several days. 

 

This is summing up the hourly values instead of giving me the max.

 

Max Hourly Value = 
MAXX (
	SUMMARIZE (
		dimtime,
		dimtime[StartOfHour]
	),
	SUM('table2'[value])
)

Table2 is the main fact table with a datetime column which is related to the dimtable .

 

5 Replies

  • Phil_Seamark's avatar
    Phil_Seamark
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi juju

     

    Can you please give some sample data.  How does your Table2 relate to your dimTime table?

      • Phil_Seamark's avatar
        Phil_Seamark
        Icon for Microsoft Employee rankMicrosoft Employee

        Hi juju

         

        I'm not sure you need an hour.  I just draged your 'StartOfHour' column to a table (formatted the time) and then just dragged your 'Value' field as well, but used the menu to use the MAX calucation to show the best value

         

         

        While this is a simple approach, I suspect you'll run into issues when you expand this to your real data.

         

        Have you considered a calculated table?

         

        Table = SUMMARIZE(
                        'table2',
                        dimtime[StartOfHour] ,
                        "Max Value" , MAX('table2'[value]) ,
                        "Min Value" , MIN('table2'[value]) ,
                        "Median Value" , MEDIAN('table2'[value]) -- ETC ETC
                        )