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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Analitika
Post Prodigy
Post Prodigy

Min function for measure in Power BI

Hi,

 

How write minimum function min for measure? min(dm) error.

12 REPLIES 12
Greg_Deckler
Super User
Super User

@Analitika This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149

The pattern is:
MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
MaxScoreMeasure = MAXX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
AvgScoreMeasure = AVERAGEX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
etc.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

I have a column date.

measure=selectvalue(date)

min(measure) getting error.

@Analitika There is no reason to get a MIN of a measure in your case. Measures return a single value. Thus, min, max, sum, average, it's all the same. Just reference the measure directly:

 

[measure]

 

Nothing around it.

If you need to get a min of a measure in a table context, then see previous message. But, you have to return a table with the measure calculated at each row and then use MINX across that table to get the minimum of the measure within that table context.

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

The problem is whenever I try add date column in visual it makes resources exceeded and table isn't being viewed.

@Analitika It's hard to say exactly where your issue is. But I don't think it is something like that measure. I feel like I have about 1/6th of the story here. What visual are you using? Are you using a date table? How many fact rows do you have? What else is in the visual? Can you use the Filter pane to limit which dates the visual is displaying?

 

It's not a typical situation where a table visual exceeds resources so there must be more to this.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

I have some columns with calculations. I wonder if I can optimize this measure:

Filtered measure_t2 = 
SUMX (
    FILTER (
        VALUES ( 'N08-Klientai'[N08_PAV]),
        [20_2_1_DATA PRADELSIMAS] >= 61 && [20_2_1_DATA PRADELSIMAS]<=90
    ),
    CALCULATE ( [18_1_0_BENDRA SKOLA (nuo istorijos pradzios)] )
)

Because table consumes many resources.

@Analitika Filtering between a range can cause performance issues. Is the [20_2_1_DATA PRADELSIMAS] a measure or column? Not sure you need the CALCULATE statement, should perhaps just be able to reference the measure directly. Depends. Any chance you can share the PBIX?

 

I did a post on optimizing DAX in a similar situation: Performance Tuning DAX - Part 1 - Microsoft Fabric Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

It is a measure. No I can't share pbix.

@Analitika OK, for any measures in the formula you posted, can you post those measure formulas as well?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

20_2_1_DATA PRADELSIMAS = 
VAR SlicerDate =
    MAX ( 'Date'[Date] )
VAR pradzia =
    CALCULATE (
        MIN ( I44_SKOL[I44_DATA_MOK]),
        FILTER ( ALL ( 'Date'[Date] ), 'Date'[Date] <= SlicerDate )
    )
VAR pradelstos_dienos =
    DATEDIFF ( pradzia, SlicerDate, DAY )
RETURN
    IF (
        ABS ( [18_1_0_BENDRA SKOLA (nuo istorijos pradzios)] ) > 0.01,
        CALCULATE ( pradelstos_dienos, FILTER ( 'Date', 'Date'[Date] <= SlicerDate ) )
    )

 

@Analitika Oh boy, I can see where this is perhaps creating some issues. Without changing too much, see if something like this helps:

Filtered measure_t2 = 
VAR __Table = 
  ADDCOLUMNS(
    DISTINCT( 'N08-Klientai'[N08_PAV] ),
    "__Measure", [20_2_1_DATA PRADELSIMAS]
  )
RETURN
SUMX (
    FILTER (
        __Table,
        [__Measure] >= 61 && [__Measure]<=90
    ),
    CALCULATE ( [18_1_0_BENDRA SKOLA (nuo istorijos pradzios)] )
)

What is [18_1_0_BENDRA SKOLA (nuo istorijos pradzios)]. If it is a measure, what is the formula?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

measure of debt

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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