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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
NewbieJono
Post Partisan
Post Partisan

Count Rows if

Hello i am trying to count rows between dates, it was wotking fine but when i add 'FACT - CW'[Transaction] = "test" as a filter it seems to ignore it. This is a calculated col

 

 

Days Old =
CALCULATE (
COUNTROWS ( 'DIM - Date Table' ),
DATESBETWEEN ( 'DIM - Date Table'[Date], 'FACT - CW'[Date of Receipt],'FACT - CW'[C-Date]-1),
'DIM - Date Table'[IsWorkingDay] = 1,
'DIM - Date Table'[IsHoliday] = 0,
'FACT - CW'[Transaction] = "test"
)

 

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @NewbieJono 

please try

Days Old =
CALCULATE (
    COUNTROWS ( 'DIM - Date Table' ),
    DATESBETWEEN (
        'DIM - Date Table'[Date],
        'FACT - CW'[Date of Receipt],
        'FACT - CW'[C-Date] - 1
    ),
    'DIM - Date Table'[IsWorkingDay] = 1,
    'DIM - Date Table'[IsHoliday] = 0,
    'FACT - CW'[Transaction] = "test",
    CROSSFILTER ( 'DIM - Date Table'[Date], 'FACT - CW'[Date], BOTH )
)

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @NewbieJono 

please try

Days Old =
CALCULATE (
    COUNTROWS ( 'DIM - Date Table' ),
    DATESBETWEEN (
        'DIM - Date Table'[Date],
        'FACT - CW'[Date of Receipt],
        'FACT - CW'[C-Date] - 1
    ),
    'DIM - Date Table'[IsWorkingDay] = 1,
    'DIM - Date Table'[IsHoliday] = 0,
    'FACT - CW'[Transaction] = "test",
    CROSSFILTER ( 'DIM - Date Table'[Date], 'FACT - CW'[Date], BOTH )
)
lukiz84
Memorable Member
Memorable Member

Your date table filters FACT - CW - not the other way around, that's why it's ignored.

 

Can you share a picture of the data model (relations)?

this as close as i can think (Dax has changed a bit), it does not work 

Days Old =
CALCULATE (
    COUNTROWS ( 'DIM - Date Table' ),
    DATESBETWEEN (
        'DIM - Date Table'[Date],
        'FACT - Casework'[Date of Receipt],
        'FACT - Casework'[COO Date] - 1
    ),
    'DIM - Date Table'[IsWorkingDay] = 1
        && 'DIM - Date Table'[IsHoliday] = 0,
    FILTER ( 'FACT - Casework', 'FACT - Casework'[Transaction] = "unallocated" )
)

The only relationship is between the date tabel and the FACT CW table

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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