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! Learn more

Reply
SanKing
Helper I
Helper I

Count of tickets within breakdown (data in two not connected tables)

Dear Power BI Community,

I would like to ask for your help - I have two tables:

Table 1 - with list of tickets & Table 2 - with breakdown time (without aby relation):

SanKing_1-1671454541799.png

Is it possible to count how many tickets were within Breakdown time (from start to end) or mark these tickets?
I tried:

Breakdown tickets? = IF(AND('Table 1'[Ticket Delivery Date]>=MIN('Table 2'[Start]), 'Table 1'[Ticket Delivery Date]<=Max('Table 2'[End])),1,0)
But unfortunately the result it's in 98% 1, exept 3 last days.

Many thanks in advance for any suggestions!
4 ACCEPTED SOLUTIONS
FreemanZ
Super User
Super User

hi @SanKing 

try to add a column in Table2 with this:

DurationCount = 
VAR _start = [Start]
VAR _end =[End]
RETURN
COUNTROWS(
    FILTER(
        Table1,
        Table1[Date]>=_start
            &&Table1[Date]<=_end
    )
)

 

i tried and it worked like this:

FreemanZ_0-1671456082828.png

 

the Table1 sample:

FreemanZ_1-1671456105502.png

 

View solution in original post

Hi @FreemanZ ,
I would like to mark (in new column) in Table 1 if ticket was affected, means 
IF ticket was printed in breakdown time "YES" (or 1), IF not "NO" (or 0).
Formula:
Breakdown tickets? = IF(AND('Table 1'[Ticket Delivery Date]>=MIN('Table 2'[Start]), 'Table 1'[Ticket Delivery Date]<=Max('Table 2'[End])),1,0)
Doesn't work.
Thank you in advance!

View solution in original post

Anonymous
Not applicable

Hi @SanKing ,

If I understand correctly, please try this:

 

Breakdown tickets? = 
VAR _date = 'Table1'[Ticket Delivery Date]
VAR _count = 
COUNTROWS(
    FILTER(
        ALL('Table2'),
        'Table2'[Start]<=_date
        && 'Table2'[End]>=_date
    )
)
VAR _result = 
IF(_count>=1,1,0)
RETURN
_result

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

Anonymous
Not applicable

Hi @SanKing ,

 

Like this?

Breakdown tickets? = 
VAR _date = 'Table1'[Ticket Delivery Date]
VAR _country = 'Table1'[Country]
VAR _count = 
COUNTROWS(
    FILTER(
        ALL('Table2'),
        'Table2'[Country]=_country
        && 'Table2'[Start]<=_date
        && 'Table2'[End]>=_date
    )
)
VAR _result = 
IF(_count>=1,1,0)
RETURN
_result

vcgaomsft_0-1672125131243.png

If I have misunderstood your needs, please feel free to contact me and preferably with expected output.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

10 REPLIES 10
FreemanZ
Super User
Super User

hi @SanKing 

try to add a column in Table2 with this:

DurationCount = 
VAR _start = [Start]
VAR _end =[End]
RETURN
COUNTROWS(
    FILTER(
        Table1,
        Table1[Date]>=_start
            &&Table1[Date]<=_end
    )
)

 

i tried and it worked like this:

FreemanZ_0-1671456082828.png

 

the Table1 sample:

FreemanZ_1-1671456105502.png

 

Thank you @FreemanZ ,
Works perfectly!
And is there a way to mark each ticket if it was affected?

hi @SanKing 

you are welcom. what does that mean?

Hi @FreemanZ ,
I would like to mark (in new column) in Table 1 if ticket was affected, means 
IF ticket was printed in breakdown time "YES" (or 1), IF not "NO" (or 0).
Formula:
Breakdown tickets? = IF(AND('Table 1'[Ticket Delivery Date]>=MIN('Table 2'[Start]), 'Table 1'[Ticket Delivery Date]<=Max('Table 2'[End])),1,0)
Doesn't work.
Thank you in advance!

hi @SanKing ,What do you mean by don't work? Wrong result or error?

Hi @FreemanZ ,
Unfortunately the results are wrong, it's in 98% 1, exept 3 last days.

Anonymous
Not applicable

Hi @SanKing ,

If I understand correctly, please try this:

 

Breakdown tickets? = 
VAR _date = 'Table1'[Ticket Delivery Date]
VAR _count = 
COUNTROWS(
    FILTER(
        ALL('Table2'),
        'Table2'[Start]<=_date
        && 'Table2'[End]>=_date
    )
)
VAR _result = 
IF(_count>=1,1,0)
RETURN
_result

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Thank you @Anonymous ,
Works perfect, 
Last question - is it possible to add IF parameter for If country from Table1 = Table2?

If I have breakdown in UK, and I don't have breakdown in FR I shouldn't mark tickets from FR.

Thanks in advance!

Anonymous
Not applicable

Hi @SanKing ,

 

Like this?

Breakdown tickets? = 
VAR _date = 'Table1'[Ticket Delivery Date]
VAR _country = 'Table1'[Country]
VAR _count = 
COUNTROWS(
    FILTER(
        ALL('Table2'),
        'Table2'[Country]=_country
        && 'Table2'[Start]<=_date
        && 'Table2'[End]>=_date
    )
)
VAR _result = 
IF(_count>=1,1,0)
RETURN
_result

vcgaomsft_0-1672125131243.png

If I have misunderstood your needs, please feel free to contact me and preferably with expected output.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Dear @Anonymous ,

Thank you!

This works perfectly!

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