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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
mglitta
Regular Visitor

calculate with max() function

Hi, 

I try to do simple calc where instead of fixed value i want to use function (max)

 

formula with fixed value works
 
REV_CW =
VAR REV_CW = CALCULATE(SUM('LOAD'[REVENUE_ACT]), 'LOAD'[TYPE] IN { "LOAD" } && 'LOAD'[WEEK] IN {11})
RETURN
REV_CW
mglitta_0-1773164938749.png

 

 
 
when i replace fixed value with function max(), it returns all rows, but total shows correctly
 
REV_CW =
VAR REV_CW = CALCULATE(SUM('LOAD'[REVENUE_ACT]), 'LOAD'[TYPE] IN { "LOAD" } && 'LOAD'[WEEK] IN {MAX(LOAD[WEEK]) })
RETURN
REV_CW
mglitta_1-1773164970239.png

 

1 ACCEPTED SOLUTION

just tested my assumption. created a side table with only week numbers from data table. made a max() function on week number and used in calculation and it works fine. simply you cant have calculation and parameter defined from the same table.

View solution in original post

4 REPLIES 4
Demert
Resolver III
Resolver III

Hi @mglitta 

 

Can you try a few things?

 

Check if Max(load[week]) actually returns 11, inside your table visual?

 

Also perhaps change your code to :
"

REV_CW =
VAR MAXWEEK = MAX(LOAD[WEEK]) 
VAR REV_CW = CALCULATE(SUM('LOAD'[REVENUE_ACT]), 'LOAD'[TYPE] IN { "LOAD" } && 'LOAD'[WEEK] = MAXWEEK, 'LOAD'[WEEK] <> BLANK()
RETURN
REV_CW

 

 

thanks Demert for your advice, I tried and it didnt help.

yes, MAX(LOAD[WEEK]) returns value 11, i test the formula in a card. 

 

mglitta_0-1773179357482.png

i suspect that the problem might be that i calculate revenue in the same table where i define the parameter from. I have to figure out the other way how to define week number parameter

 

just tested my assumption. created a side table with only week numbers from data table. made a max() function on week number and used in calculation and it works fine. simply you cant have calculation and parameter defined from the same table.

Hello @mglitta,
Thanks for the update and for sharing the solution.

It’s good to hear that using a separate table for the week parameter resolved the issue. This will assist other community members in resolving similar issues more efficiently.
Also thanks to @Demert for the earlier suggestions.

Best regards,
Ganesh Singamshetty.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.