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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.