Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Color format by category in stacked chart with condition.

Hello,

I want to make a mesure that make a colorisation when a value is more than another value select on a slicer filter. This measure will be integrate on a stacked diagram. I've already try to write a DAX code for this problematic but it doesn't work : 
---------------------------------------------------
Pareto art val CF =
VAR ParetoValue = [_Pareto article val %]
VAR SeuilPareto = [Valeur Seuil pareto]

 

VAR Categorie =
        ADDCOLUMNS('Data',
        "Statut ancienneté dyna",
        if([_Pareto article val %] <= [Valeur Seuil pareto],'Data'[Statut ancienneté],"Autre"
        ))
   
RETURN
IF(
    [_Pareto article val %] <= [Valeur Seuil pareto] ,
    SWITCH(
        ,
        Categorie = "Catégorie 1 :  <= 1 mois", "#118DFF",
        Categorie = "Catégorie 2 :  <= 3 mois", "#EFD807",
        Categorie = "Catégorie 3 :  <= 6 mois", "#F6A02F",
        Categorie = "Catégorie 4 :  > 6 mois", "#FA0400",
        Categorie = "Autre", "#a9a9a9"
    )
)
------------------------
The two measure initialize at the start of the DAX code return just a value.
Someone can help me please. 

2 Replies

  • Anonymous , hope you are using true in switch

    you can have a measure like

     

    IF(
    [_Pareto article val %] <= [Valeur Seuil pareto] ,
    SWITCH( true() ,
    Max('Data'[Statut ancienneté]) = "Catégorie 1 : <= 1 mois", "#118DFF",
    Max('Data'[Statut ancienneté]) = "Catégorie 2 : <= 3 mois", "#EFD807",
    Max('Data'[Statut ancienneté]) = "Catégorie 3 : <= 6 mois", "#F6A02F",
    Max('Data'[Statut ancienneté]) = "Catégorie 4 : > 6 mois", "#FA0400",
     "#a9a9a9"
    )
    )

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for your response but this is not the expect result :

      In this case I don't know if they have a several category for one value like for this graph: