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
Learner_SG
Helper IV
Helper IV

Error in selecting the highest values

hi , could help where I am wrong. I need to select the max value . but all the values gets selected. Where should I correct it?

Learner_SG_0-1652715400880.png

3-6PM highest = calculate(MAX(measurement[sum_wc_consumption]), filter(measurement, measurement[Parsed_Date]>= Today() -7 && measurement[Parsed_Date]<=Today()-6 ),measurement[Intervals]="3PM-6PM")

 

6 REPLIES 6
v-xiaotang
Community Support
Community Support

Hi @Learner_SG 

I just want to confirm if you resolved this issue? If yes, you can accept the answer helpful as the solution or share you method and accept it as solution, thanks for your contribution to improve Power BI.

If you need more help, please let me know.

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

johnt75
Super User
Super User

Try

3-6PM highest =
CALCULATE (
    MAX ( measurement[sum_wc_consumption] ),
    REMOVEFILTERS ( measurement ),
    measurement[Parsed_Date]
        >= TODAY () - 7
        && measurement[Parsed_Date]
            <= TODAY () - 6,
    measurement[Intervals] = "3PM-6PM"
)

@johnt75 thanks for the reply. But it does not work out in the intended manner.

The result is given below. It selects all the timing it seems. 

My aim is to get the max values in the specified time and based on that select the time and day.

 

Learner_SG_0-1652748281328.png

 

 

 

If I understand you correctly you want to get the time and day at which the max value occurs. You can do this with TOPN, like

Time of max value =
SELECTCOLUMNS (
    CALCULATETABLE (
        TOPN ( 1, measurement, measurement[sum_wc_consumption] ),
        REMOVEFILTERS ( measurement ),
        measurement[Parsed_Date]
            >= TODAY () - 7
            && measurement[Parsed_Date]
                <= TODAY () - 6,
        measurement[Intervals] = "3PM-6PM"
    ),
    "@val", measurement[Time]
)

Hi @johnt75 ,yes correct . I need to select 2 highest from each timezone..for this expression it is 3-6pm. 1 for each day(based on 6th and 7th day). But when I used ur expression it gives me the following error.

Learner_SG_0-1652779618766.png

 

I think that means that there are multiple entries which share the same value for sum_wc_consumption.

You'll need to use some logic which makes sense for your business case to choose one, but you can add additional criteria into the TOPN function based on different columns. For example, you could choose the earliest occurence with something like

TOPN ( 1, measurement, measurement[sum_wc_consumption], DESC, measurement[Parsed_Date], ASC, measurement[Time], ASC ),

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.