Johnny Spindler
Johnny Spindler

Reputation: 456

How to Count Results of Measure in a Table in Power BI

I have a measure "Classification" that classifies vendors by soled items. The table looks something like this:

Vendor Soled Classification
Ven1 10 B
Ven2 5 C
Ven3 100 A
Ven4 15 B

I am trying to build this table by counting the vendors fitting the Classification Measure:

CountClass Classification
1 A
2 B
1 C

But when I put the "Classification" Measure in a Table and make a Count on Vendor on the visualization I get this result:

Vendor Classification
4 A

It just sums the vendors up and only shows the "Classification" = A. If I do not set a count on vendors, I can see all Classifications.

Here is how I calculate the "Classification":

Classification = 
SWITCH(TRUE(),
    SUMX(SalesTable, SalesTable[Soled_ALLPREV]) >= [Soled ALL A CutOff],"A",
    SUMX(SalesTable, SalesTable[Soled_ALLPREV]) >= [Soled ALL B CutOff]
    && SUMX(SalesTable, SalesTable[Soled_ALLPREV]) < [Soled ALL A CutOff],"B",
    SUMX(SalesTable, SalesTable[Soled_ALLPREV]) >= [Soled ALL C CutOff]
    && SUMX(SalesTable, SalesTable[Soled_ALLPREV]) < [Soled ALL B CutOff],"C",
    SUMX(SalesTable, SalesTable[Soled_ALLPREV]) >= [Soled ALL D CutOff]
    && SUMX(SalesTable, SalesTable[Soled_ALLPREV]) < [Soled ALL C CutOff],"D",
    "N/A")

This how it looks: enter image description here

If I sum up on Vendor or use the suggested Measure

Measure 2 = calculate(countrows(VALUES(table[Vendor])))

The Calssification Measure still only shows "A" only: enter image description here

The problem seams to be that I want to use only measures on visuals and this needs some level of detail otherwhise it just sums up. I belive that my Classification measure is the one that needs to be able to calculate also without other columns in the visual.

How can I make this work? Please help me.

Upvotes: 0

Views: 1427

Answers (1)

msta42a
msta42a

Reputation: 3741

THIS work for classification as COLUMN:

Create a simple measure:

CountOf: calculate(countrows(VALUES(table[Vendor])))

enter image description here

https://dax.guide/countrows/

EDIT:

Classification as measure. Add additional unconnected table "class_label" as:

enter image description here

Add another measure:

Tst = if(SELECTEDVALUE(class_label[Classification]) = [Classification_mesure], clas[CountOf], 0)

Use these new objects together.

enter image description here

Upvotes: 1

Related Questions