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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Jean-Mi64
Helper I
Helper I

création d'une mesure avec filtre

Bonjour 

Dans une table, j’ai une colonne de produits, une colonne de quantité de produits et une colonne de date de livraison.

Certains produits peuvent avoir plusieurs quantités selon la date de livraison.

Je souhaite créer une mesure, pour une date de livraison choisie, qui compte le nombre de produit en ne gardant que la quantité la plus basse de chaque produit

JeanMi64_0-1739532881251.png

Merci

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hello,AilleryO,thanks for your concern about this issue.

Your answer is excellent!
And I would like to share some additional solutions below.

 
Hi,@Jean-Mi64 .I am glad to help you.
1.You can group data using ALL()/ALLSELECTED() +var variables
The var variable gets the current value of each row, enabling grouping calculations.
The measure calculates the minimum number within the same group.
Then you mark the target result as 1 by creating a new measure, and then set the measure to display only the data in the current row with a value of 1.
Like this:

vjtianmsft_0-1739758225560.png
This is my test code:

vjtianmsft_1-1739758250767.png

M_minPerPro =
VAR _groupPorduct =
    MIN ( 'TestTable'[Product] )
VAR _result =
    CALCULATE (
        MIN ( 'TestTable'[Quantities] ),
        FILTER ( ALLSELECTED ( 'TestTable' ), 'TestTable'[Product] = _groupPorduct )
    )
RETURN
    _result



M_Filter = 
VAR _groupPorduct = MIN ( 'TestTable'[Product] ) //Get the current product name for each row in the table visual.
VAR _result =
    CALCULATE (
        MIN ( 'TestTable'[Quantities] ),
        FILTER ( ALLSELECTED ( 'TestTable' ), 'TestTable'[Product] = _groupPorduct )
    )
VAR _quantities = MIN ( 'TestTable'[Quantities] ) // Get the current Quantities for each row in the table visual.
RETURN
    IF ( _quantities = _result, 1, 0 )

2.The same effect can be achieved using ALLEXCEPT():

vjtianmsft_2-1739758580128.png

URL:

ALLEXCEPT function (DAX) - DAX | Microsoft Learn


I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
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

2 REPLIES 2
Anonymous
Not applicable

Hello,AilleryO,thanks for your concern about this issue.

Your answer is excellent!
And I would like to share some additional solutions below.

 
Hi,@Jean-Mi64 .I am glad to help you.
1.You can group data using ALL()/ALLSELECTED() +var variables
The var variable gets the current value of each row, enabling grouping calculations.
The measure calculates the minimum number within the same group.
Then you mark the target result as 1 by creating a new measure, and then set the measure to display only the data in the current row with a value of 1.
Like this:

vjtianmsft_0-1739758225560.png
This is my test code:

vjtianmsft_1-1739758250767.png

M_minPerPro =
VAR _groupPorduct =
    MIN ( 'TestTable'[Product] )
VAR _result =
    CALCULATE (
        MIN ( 'TestTable'[Quantities] ),
        FILTER ( ALLSELECTED ( 'TestTable' ), 'TestTable'[Product] = _groupPorduct )
    )
RETURN
    _result



M_Filter = 
VAR _groupPorduct = MIN ( 'TestTable'[Product] ) //Get the current product name for each row in the table visual.
VAR _result =
    CALCULATE (
        MIN ( 'TestTable'[Quantities] ),
        FILTER ( ALLSELECTED ( 'TestTable' ), 'TestTable'[Product] = _groupPorduct )
    )
VAR _quantities = MIN ( 'TestTable'[Quantities] ) // Get the current Quantities for each row in the table visual.
RETURN
    IF ( _quantities = _result, 1, 0 )

2.The same effect can be achieved using ALLEXCEPT():

vjtianmsft_2-1739758580128.png

URL:

ALLEXCEPT function (DAX) - DAX | Microsoft Learn


I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

AilleryO
Memorable Member
Memorable Member

Bonjour,

Si vous ne sélectionnez que des dates uniques (et pas des périodes), ceci devrait suffire :

Mesure = CALCULATE( MIN( Quantite ) , ALL( Quantite ) )

Mais il peut y avoir d'autres filtres à gérer ?

Pour des périodes il est possible que l'itération soit nécessaire avec MINX.

Mais difficle d'en dire plus sans mieux connaître la situation.

J'espère que cela répond au besoin...

Helpful resources

Announcements
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.