Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Maximum Value from table

Hi everyone, 

Im having difficulty displaying my maximum value from a table, i would appreciate if anyone could help me.

The error shows that " Argument "6" in function SWITCH is required"

sabrina_az_0-1639597973641.png

My code:

Max =
VAR ValueDisplayed=
CALCULATETABLE(
ADDCOLUMNS(
    SUMMARIZE ('energykwh energydata','energykwh energydata'[DATE],'energykwh energydata'[Time],'energykwh energydata'[energydata_value]),
    "@abc",[energydata_value]
),
ALLSELECTED()
)
VAR MinVal = MINX(ValueDisplayed, [@ABC])
VAR MaxVal=MAXX(ValueDisplayed, [@abc])
VAR CurrentVaL= [energydata_value]
VAR Result=
    SWITCH(
        TRUE(),
        CurrentVal= MinVal, 1,
CurrentVaL= MaxVal,2,)

RETURN
    Result

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Please note that your code has an extra comma at the underscore I marked:

 

Eyelyn9_0-1639979365258.png

 

If you just want to apply a flag for the max and min value, you could simply use:

Column = 
var _max=MAX('energykwh energydata'[energydata_value])
var _min=MIN('energykwh energydata'[energydata_value])
return SWITCH(TRUE(), [energydata_value]=_max,2,[energydata_value]=_min,1)

 

Best Regards,
Eyelyn Qin
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

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

 

Please note that your code has an extra comma at the underscore I marked:

 

Eyelyn9_0-1639979365258.png

 

If you just want to apply a flag for the max and min value, you could simply use:

Column = 
var _max=MAX('energykwh energydata'[energydata_value])
var _min=MIN('energykwh energydata'[energydata_value])
return SWITCH(TRUE(), [energydata_value]=_max,2,[energydata_value]=_min,1)

 

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

smpa01
Super User
Super User

@Anonymous  get rid of the last comma in SWITCH

 

VAR Result=
    SWITCH(
        TRUE(),
        CurrentValMinVal1,
CurrentVaLMaxVal,2)

 

RETURN
    Result
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

Hi, i still am unabe to extract the maximum value out from the table. Do you by any chance know how to extract the value? My code was not working. This is my table.

sabrina_az_0-1639641701829.png

 

@Anonymous  can you please provide some sample dat and expected output?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.