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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
jondufault
Frequent Visitor

Compute stat for date range and same day of week

I have a user that wants a table that computes the number of invoices late for a date range and then provides a summary for the whole period. I'm having trouble even conceptualizing how the calculate or filter DAX would be. I tried joining to a duplicate table on the period alone, but when I put it in a visualization it shows the same total for everything/for the entire dataset.

 

Data:

 

jondufault_2-1692032082610.png

 

Desired Output

 

jondufault_3-1692032099053.png

 

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @jondufault ,

According to your description, here's my solution.

1.Create a new Status table as below, don't make relationship with the fact table.

vyanjiangmsft_0-1692155095593.png

2.Create two measures:

Count Date =
COUNTROWS (
    FILTER ( ALLSELECTED ( 'Table' ), 'Table'[status] = MAX ( 'Status'[Status] ) )
) + 0
Count Period =
COUNTROWS (
    FILTER (
        ALL ( 'Table' ),
        'Table'[period]
            IN VALUES ( 'Table'[period] )
                && 'Table'[status] = MAX ( 'Status'[Status] )
    )
)

Put the new status column and two measures in a visual, get the correct result:

vyanjiangmsft_1-1692155287252.pngvyanjiangmsft_2-1692155302439.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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-yanjiang-msft
Community Support
Community Support

Hi @jondufault ,

According to your description, here's my solution.

1.Create a new Status table as below, don't make relationship with the fact table.

vyanjiangmsft_0-1692155095593.png

2.Create two measures:

Count Date =
COUNTROWS (
    FILTER ( ALLSELECTED ( 'Table' ), 'Table'[status] = MAX ( 'Status'[Status] ) )
) + 0
Count Period =
COUNTROWS (
    FILTER (
        ALL ( 'Table' ),
        'Table'[period]
            IN VALUES ( 'Table'[period] )
                && 'Table'[status] = MAX ( 'Status'[Status] )
    )
)

Put the new status column and two measures in a visual, get the correct result:

vyanjiangmsft_1-1692155287252.pngvyanjiangmsft_2-1692155302439.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

lbendlin
Super User
Super User

Your logic for "Count Period"  is not clear. Please elaborate.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors