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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Return the smallest value from a column based on the minx function

Hey Guys ! Hope Everything is good for you all !

I'm having some difficulties making a mesure to return values based on an interactive function ( Minx in this case ).
Basically , I'm Calculating MTBF. ( Mean Time Between Failures ) in relation with all machines in my Dimension table.

MTBF = DIVIDE([Tempo Disponível],[Quantidade de Paradas])
Menor MTBF = MINX(VALUES(F_MTBF[machine]),'Mesures MTBF'[MTBF])

And this works fine.

The problem is, when I'm trying to return the machine of the smallest Value. Because it is an interactive function and is defined as a measure, I cannot use the "Min" function to do this calculation.

Using filters , I'm able to reach my goal as show below:

Lucasbral_0-1646929887474.png

N Superior Filter and THe function Menor 

I believe it's a TOPN function but when I do this type of calculation using Minx as an expression I get an error because it uses multiple columns and not a scalar (Due to the fact that MINX is an interactive function).

Lucasbral_1-1646930211721.png

Its My dimension Table

So, How can i create a dax measure using the same way of this filter ?




1 ACCEPTED SOLUTION
Anonymous
Not applicable

Finally found a solution :

Thank you guys !

Menor Máquina = 
VAR Tabela =
    SUMMARIZE (
        F_MTBF,
        F_MTBF[Equipamento],
        "Total Vendas", [Menor MTBF]
    )
    
VAR MenorMTBF = 
MINX (
    SUMMARIZE (
        F_MTBF,
        F_MTBF[Equipamento],
        "Maior Valor", [Menor MTBF]
    ),
    [Maior Valor]
)
RETURN
    CALCULATE (
        FIRSTNONBLANK (
            F_MTBF[Equipamento],
            1
        ),
        FILTER (
            Tabela,
            [Total Vendas] = MenorMTBF
        )
    )

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Finally found a solution :

Thank you guys !

Menor Máquina = 
VAR Tabela =
    SUMMARIZE (
        F_MTBF,
        F_MTBF[Equipamento],
        "Total Vendas", [Menor MTBF]
    )
    
VAR MenorMTBF = 
MINX (
    SUMMARIZE (
        F_MTBF,
        F_MTBF[Equipamento],
        "Maior Valor", [Menor MTBF]
    ),
    [Maior Valor]
)
RETURN
    CALCULATE (
        FIRSTNONBLANK (
            F_MTBF[Equipamento],
            1
        ),
        FILTER (
            Tabela,
            [Total Vendas] = MenorMTBF
        )
    )
Anonymous
Not applicable

Hello @goncalogeraldes  ! , Thanks for your Answer !

I tried and returned an Empty Value

I created a RankX function to figure it out if there any problem and my rank starts from value 2 ( Skipping 1 in ASC ordering )

Rank Machine = RANKX(ALL(D_Machine[machine]),'Medidas MTBF'[MTBF],,ASC,Dense)

Lucasbral_0-1646933106229.png


But, modifing your measure to show 2 or 5 itens continues empty in return.

Regards !



Try this:

Rank Machine =
RANKX (
    ALLNOBLANKROW ( D_Machine[machine] ),
    'Medidas MTBF'[MTBF],
    ,
    ASC,
    DENSE
)
Anonymous
Not applicable

Worked ! Thank You !


But, after a few tests i realized that your formula to the smallest machine is not working.

Returns a blank value 

And if I limit the machines, the result of the lowest value doesn't match

Lucasbral_1-1646938737200.png

 

 

Anonymous
Not applicable

Hi @Anonymous,

Can you please share a pbix or some dummy data that keep raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

goncalogeraldes
Super User
Super User

Hello there @Anonymous ! Check if this works for you:

 

Menor MTBF =
CALCULATE (
    SELECTEDVALUE ( F_MTBF[machine] ),
    TOPN (
        1,
        SUMMARIZE (
            F_MTBF,
            F_MTBF[machine],
            "mtbf", DIVIDE( [Tempo Disponível] , [Quantidade de Paradas] )
        ),
        [mtbf], DESC
    )
)

 

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.