Forum Discussion

gelsonwirtijr's avatar
gelsonwirtijr
Frequent Visitor
2 years ago
Solved

how to plot classification data made using a dax measure

Hello, I have the measure:

Classificação Cliente Peças =
VAR TotalServicos = [Realizado]
RETURN
    SWITCH(
        TRUE(),
        TotalServicos >= 1000000, "K",
        TotalServicos >= 300000 && TotalServicos < 1000000, "A",
        TotalServicos >= 50000 && TotalServicos < 300000, "B",
        TotalServicos < 50000, "C",
        BLANK()
    )

which classifies my customers based on how much they spent. I would like to plot it in a bar graph, that is, the X axis should be the classes "K", "A", "B" and "C" and the Y axis the quantity of each class. I tried to do it by creating a table as follows:

ClassificaçãoPeças =
SUMMARIZE(
    dClientes,
    dClientes[Cliente],
    "Classificação Peças", [Classificação Cliente Peças]
)

That's the idea, but I can't filter by date, as it's not possible to make any relationship. Is there any way I can plot this graph but it reacts to the year filter?

Below is the measure [Realizado], used in the classification:

Realizado = CALCULATE([FY Fat.])

FY Fat. = var vFY =[FY Seleção]
RETURN CALCULATE([Total Fat.], FILTER('dCalendário', 'dCalendário'[Ano FY]=vFY))

FY Seleção = var vFY = IF(MONTH([Data Seleção])=11|| MONTH([Data Seleção])=12, YEAR([Data Seleção])+1, YEAR([Data Seleção]))
RETURN INT(FORMAT(vFY,"####"))
Total Fat. =
CALCULATE(SUM(fFaturamento[Valor Bruto]), fFaturamento[Setor]="Balcão")+0


  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi gelsonwirtijr 

    You can try to create a new table, then put the type to the new table

    e.g 

    Type={"A","B","C","K"}

    Then create a new measure

    e.g

    Counts =
    CALCULATE (
        COUNTROWS ( dClientes ),
        FILTER ( dClientes, [Classificação Cliente Peças] IN VALUES ( 'Type'[Value] ) )
    )
    

    Then put the Counts measure to the y-axis, then it can be affected by the date filter.

     

    Best Regards!

    Yolo Zhu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi gelsonwirtijr 

    You can try to create a new table, then put the type to the new table

    e.g 

    Type={"A","B","C","K"}

    Then create a new measure

    e.g

    Counts =
    CALCULATE (
        COUNTROWS ( dClientes ),
        FILTER ( dClientes, [Classificação Cliente Peças] IN VALUES ( 'Type'[Value] ) )
    )
    

    Then put the Counts measure to the y-axis, then it can be affected by the date filter.

     

    Best Regards!

    Yolo Zhu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.