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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
abgnfirdaus
Helper I
Helper I

count no. of test

Hello there, I need some help here. Based on the table below:

DateEquipment no.Result
2/1/2020APriority 1
2/2/2020BPriority 1
3/4/2019APriority 2
4/3/2018ANo action needed

 

I want to create a column that can count number of test per equipment and only show latest date of equipment. The table should be like this:

DateEquipment no.ResultCount of test
2/1/2020APriority 13
2/2/2020BPriority 11

 

Hope you guys help me by showing some tutorial. thank you very much 

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @abgnfirdaus 

 

try this code to add a new table with DAX:

calctables_formulabarempty

 

New Table = 
ADDCOLUMNS (
    VALUES ( 'Table'[Equipment no.] ),
    "Date",
        CALCULATE (
            MAX ( 'Table'[Date] ),
            ALLEXCEPT ( 'Table', 'Table'[Equipment no.] )
        ),
    "Result",
        CALCULATE (
            MAX ( 'Table'[Result] ),
            FILTER (
                'Table',
                'Table'[Equipment no.] = EARLIER ( [Equipment no.] )
                    && 'Table'[Date]
                        = CALCULATE (
                            MAX ( 'Table'[Date] ),
                            ALLEXCEPT ( 'Table', 'Table'[Equipment no.] )
                        )
            )
        ),
    "Count of Test",
        CALCULATE (
            COUNTROWS ( 'Table' ),
            FILTER ( 'Table', 'Table'[Equipment no.] = EARLIER ( [Equipment no.] ) )
        )
)

 

Output:

VahidDM_0-1643079622523.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
VahidDM
Super User
Super User

Hi @abgnfirdaus 

 

try this code to add a new table with DAX:

calctables_formulabarempty

 

New Table = 
ADDCOLUMNS (
    VALUES ( 'Table'[Equipment no.] ),
    "Date",
        CALCULATE (
            MAX ( 'Table'[Date] ),
            ALLEXCEPT ( 'Table', 'Table'[Equipment no.] )
        ),
    "Result",
        CALCULATE (
            MAX ( 'Table'[Result] ),
            FILTER (
                'Table',
                'Table'[Equipment no.] = EARLIER ( [Equipment no.] )
                    && 'Table'[Date]
                        = CALCULATE (
                            MAX ( 'Table'[Date] ),
                            ALLEXCEPT ( 'Table', 'Table'[Equipment no.] )
                        )
            )
        ),
    "Count of Test",
        CALCULATE (
            COUNTROWS ( 'Table' ),
            FILTER ( 'Table', 'Table'[Equipment no.] = EARLIER ( [Equipment no.] ) )
        )
)

 

Output:

VahidDM_0-1643079622523.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

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.

Top Solution Authors
Top Kudoed Authors