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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
joglidden2
Post Patron
Post Patron

Need a static measure that doesn't change across rows

Do I need to even describe the problem any further? How is this not a previous post?

 

Here's the measure: 

__max = max(SITE[Personnel SC Count])
The value is 2047.
In a table, or calculated column, it changes on every row. I want it to be static on the value of 2047. 
How is this done?
 
1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @joglidden2,

It sounds like you want to get the specific value from the table without filter effects. For this scenario, I'd like to suggest you add the 'all' function on the table to ignore the filter effect, then you can get the static values.

Measure =
CALCULATE ( MAX ( SITE[Personnel SC Count] ), ALL ( SITE ) )

Reference link of the detailed description of all functions:

Managing “all” functions in DAX: ALL, ALLSELECTED, ALLNOBLANKROW, ALLEXCEPT - SQLBI

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

12 REPLIES 12
joglidden2
Post Patron
Post Patron

Thank you everyone for your suggestions. Solving this problem turned out to be far easier, faster, and more reliable in SQL using stored procedures, functions, views, etc.  This is what I would recommend to anyone pursuing this sort of problem with SQL Server as a data source. That said, the accepted solution appears to be workable. 

v-shex-msft
Community Support
Community Support

HI @joglidden2,

It sounds like you want to get the specific value from the table without filter effects. For this scenario, I'd like to suggest you add the 'all' function on the table to ignore the filter effect, then you can get the static values.

Measure =
CALCULATE ( MAX ( SITE[Personnel SC Count] ), ALL ( SITE ) )

Reference link of the detailed description of all functions:

Managing “all” functions in DAX: ALL, ALLSELECTED, ALLNOBLANKROW, ALLEXCEPT - SQLBI

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
joglidden2
Post Patron
Post Patron

Thanks everyone for your help and suggestions. Basically, I'm giving up on doing this level of custom development in Power BI. It's just too much trouble, and it's a lot easier doing it in SQL Server and in code (C#, Java). Power BI is great for reporting results, but I now realize that it's more efficient and easier to build the logic elsewhere. 

Caz_16
Helper II
Helper II

@joglidden2 

 

You could also use a variable.

___max = 
VAR Max_Personnel = 
MAX(ALL(SITE[Personnel SC Count]))
RETURN

Max_Pesonnel

 

You can then use that variable for further calculations using DAX after the RETURN character. 

 

Nope. "The MAX function only accepts a column reference as an argument." Good idea though.

Im not sure why mine didn't work. SITE[Personnel SC Count] is a column, right? Try removing the "ALL", just pass it your column. Some sample data would help everyone understand the issue a little better. 

 

I tested this with my own dataset and it works perfectly. It will produce the same number no matter what I table or Viz i apply that measure to.

mhossain
Solution Sage
Solution Sage

@joglidden2 

I believe you are dragging this measure to table and there are are other column, so obviously it is showing max at Other column level.

 

You can try:

__max = 

 CALCULATE (

                       max(SITE[Personnel SC Count])

                  ,

                      ALL(Other column)

                   )

 

Please update measure, hope above is clear and it helps.

 

That's right, I'm dragging the measure to a new column in the table. Then the table gives me the measure value for each row, which is not what I want. 

Yes, there are other columns. I tried a different column (in the 'ALL' expression) and got the same result as before. What you suggested didn't work. 

@joglidden2 

Share the pbix with sample data if possible.

@mhossain thanks for your suggestions. I can't provide the report or data because it's sensitive information. I'm giving up on PBI for this type of development. 

amitchandak
Super User
Super User

@joglidden2 , Try like

 

__max = max(allselected(SITE), SITE[Personnel SC Count])

 

or

 

__max = max(all(SITE), SITE[Personnel SC Count])

No dice. "A single value for column ... cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.