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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
kotlonarendra
Frequent Visitor

How to get counts of records for a column based on two date columns

Input: 

 GuideApprovalRequestDateGuideApprovalDate
P1272_NSTwa_N2NozzleSensorSetup_Rev27/1/2021 13:389/30/2021 15:47
P1272_NSTwa_WaferStrandingProcedure_Rev17/1/2021 13:559/30/2021 15:47
P1272_NSTwa_E3DashboardTrace_Rev17/1/2021 13:549/30/2021 15:47
P1272_NSTwa_VortexFlowmeterFlaring_Rev17/1/2021 13:349/30/2021 15:47
P1272_NSTwa_WaferUnStrandingProcedure_Rev17/1/2021 13:569/30/2021 15:47

 

Result: 

 Count GuideApprovalRequestDateCount GuideApprovalDate
9/30/2021 15:4705
7/1/2021 13:3850
1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @kotlonarendra ,

 

I don't understand why only one result of GuideApprovalRequestDate is kept in your result, and the others are removed.
This form needs a unique field, if not, then I will sort by GuideApprovalDate.

vchenwuzmsft_1-1655090206320.gif

Unpivot this table.

vchenwuzmsft_2-1655090291944.gif

 

And then get the most date of the current group via this code:

Column =
VAR _a =
    CALCULATE (
        MIN ( 'Table'[Value] ),
        FILTER (
            'Table',
            [GuideApprovalDate] = EARLIER ( 'Table'[GuideApprovalDate] )
                && [Attribute] = "Group.GuideApprovalRequestDate"
        )
    )
RETURN
    IF ( [Attribute] = "Group.GuideApprovalDate", [Value], _a )

 

At last, put this column in the Rows of matrix table and Attribute in the Columns.

vchenwuzmsft_3-1655090780067.png

Result:

vchenwuzmsft_4-1655090805967.png

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

2 REPLIES 2
v-chenwuz-msft
Community Support
Community Support

Hi @kotlonarendra ,

 

I don't understand why only one result of GuideApprovalRequestDate is kept in your result, and the others are removed.
This form needs a unique field, if not, then I will sort by GuideApprovalDate.

vchenwuzmsft_1-1655090206320.gif

Unpivot this table.

vchenwuzmsft_2-1655090291944.gif

 

And then get the most date of the current group via this code:

Column =
VAR _a =
    CALCULATE (
        MIN ( 'Table'[Value] ),
        FILTER (
            'Table',
            [GuideApprovalDate] = EARLIER ( 'Table'[GuideApprovalDate] )
                && [Attribute] = "Group.GuideApprovalRequestDate"
        )
    )
RETURN
    IF ( [Attribute] = "Group.GuideApprovalDate", [Value], _a )

 

At last, put this column in the Rows of matrix table and Attribute in the Columns.

vchenwuzmsft_3-1655090780067.png

Result:

vchenwuzmsft_4-1655090805967.png

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

kotlonarendra
Frequent Visitor

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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