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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
rafiql09
Frequent Visitor

Count rows of a table that exist in another table with date comparison

rafiql09_0-1672913308456.png

I want row count of ST_setups[PO_No_Key] table those also exists in inv_challan_gatepass.. table where for those PO_No_Key inv_challan_gatepass[shipment_date] is equal or earlier than ST_setups[delivery_date].  Date (ST_setups[delivery_date]) is selected from date slicer using DAX.

 

I just want to count PO_No_Key shipped on or before delivery date. Date is selected from slicer.

 

Thanks in advance.

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Try

 

Shipped on or before delivery =
COUNTROWS (
    FILTER (
        'inv_challan_gatepass',
        'inv_challan_gatepass'[shipment_date]
            <= RELATED ( ST_Setups[delivery_date] )
    )
)

 

View solution in original post

13 REPLIES 13
johnt75
Super User
Super User

Try

 

Shipped on or before delivery =
COUNTROWS (
    FILTER (
        'inv_challan_gatepass',
        'inv_challan_gatepass'[shipment_date]
            <= RELATED ( ST_Setups[delivery_date] )
    )
)

 

Thanks Johnt75, it taises syntax error. Here is more sample data . Count is three here.

 

rafiql09_0-1672915925162.png

 

What is the error it is raising ?

rafiql09_0-1672917293292.png

Why you write PO_No_Key column infront of the table name!!

 

That's my copy & paste error. I've edited my original post to correct the mistake.

Here how are we checking PO_No_Key of ST_Setups table exist in inv_challan_gatepass table?

The slicer on the delivery date will filter ST_Setups and that filter will be passed to inv_challan_gatepass by the relationship

I am not getting the right output. Is this relationship correct?

rafiql09_0-1672918324708.png

 

Yes, that looks correct. Can you paste some sample data in a format that can be copied & pasted ?

This PO_No_Key 20409 is shpped before delivery date. but my report is not returnng.

That works for me using the data you shared. Do you have any other filters being applied ?

Grab the query generated for the visual in Performance Analyzer and have a look at it in DAX Studio. That might give you some pointers.

Does it return count 1(one) if you select 30th august on your date slicer ? as 20409 its delivery date is 30th 2022 august and ship_date is 26th august 2022

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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