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
GoodMan85
Frequent Visitor

Help Me count

Hello guys,
i have a problem with my file, i can't make a count.
Specifically I should count how many items are of category "A" and "UP" from the table.
The fields where the "UP" state originates is the following:
KPI L-G = IF ([DIFF L-G] <0, "DWN", IF ([DIFF L-G]> 0, "UP", "INV"))
DIFF L-G = [Adv Jul] - [Adv Down]
Adv Down = CALCULATE (SUM ('SM-ABC Analysis' [Adv.]), 'SM-ABC Analysis' [Month] = "6")
Adv Jul = CALCULATE (SUM ('SM-ABC Analysis' [Adv.]), 'SM-ABC Analysis' [Month] = "7")

Thank you all

BI.PNG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @GoodMan85 

I build a sample to have a test. 

1.png

Try this measure.

CountANeg = 
CALCULATE (
    DISTINCTCOUNT ( 'SM-ABC Analysis'[Codice Art] ),
    FILTER (
        'SM-ABC Analysis',
        'SM-ABC Analysis'[Classic QTY] = "A"
            && CALCULATE (
                [DIFF L-G],
                ALLEXCEPT (
                    'SM-ABC Analysis',
                    'SM-ABC Analysis'[Codice Art],
                    'SM-ABC Analysis'[Classic QTY]
                )
            ) > 0
    )
)

Result is as below.

1.png

Best Regards,
Rico Zhou

 

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

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

@GoodMan85 Try using COUNTX(FILTER(...),...)



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @GoodMan85 

I build a sample to have a test. 

1.png

Try this measure.

CountANeg = 
CALCULATE (
    DISTINCTCOUNT ( 'SM-ABC Analysis'[Codice Art] ),
    FILTER (
        'SM-ABC Analysis',
        'SM-ABC Analysis'[Classic QTY] = "A"
            && CALCULATE (
                [DIFF L-G],
                ALLEXCEPT (
                    'SM-ABC Analysis',
                    'SM-ABC Analysis'[Codice Art],
                    'SM-ABC Analysis'[Classic QTY]
                )
            ) > 0
    )
)

Result is as below.

1.png

Best Regards,
Rico Zhou

 

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

Thank you so much @Anonymous !

Great, working good.

@Greg_Deckler 

I tried to do as you suggested, I have no errors in the formula but it does not allow me to view any results.

 

CountANeg = COUNTX(FILTER('SM-Analisi ABC', 'SM-Analisi ABC'[Classe Qty] = "A"), [DIFF L-G] < 0)

 

Do you have any suggestions?

@GoodMan85 I'd need some sample data to test with, I don't want to hand type in a bunch of data.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.