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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Return count of customer number and status based on date

I have gone around again and again and cannot solve this problem. I am trying to determine at a specific point in time what the status of a "Customer Number" is. For example, referencing the below table, on 1/1/2011 5835 would be "OPEN". If I move the date to 3/10/2011, it would be "CLOSED".

 

Customer NumberTransaction DateDescriptionNumber
58359/9/2010OPEN

1

58351/20/2011CLOSED2
58354/28/2011OPEN3
58355/26/2011CLOSED4
58356/24/2011

OPEN

5

58358/11/2011

CLOSED

6

58359/1/2011

OPEN

7

58359/19/2011

CLOSED

8

 

I have thousands of these, and ultimately want to know that on X date, the count of open is Y and the count of closed is Z for all "Customer Numbers". 

 

I referenced this thread which is similar, but isn't getting me the results I want primarily because it's using MAX Date for all rows when I want to specify a specific point in time.

 

Any help is appreciated, I have people doing a bunch of work but they don't know how much they're doing or have been doing.

3 REPLIES 3
v-lili6-msft
Community Support
Community Support

HI, @Anonymous 

After my research, you could try this way as below:

Step1:

Create a separate date table to specify a specific point in time. 

Step2:

Create the two measure as below:

count of OPEN =
VAR _table =
    ADDCOLUMNS (
        'Table',
        "_lastdate", CALCULATE (
            MAX ( 'Table'[Transaction Date] ),
            FILTER (
                ALLEXCEPT ( 'Table', 'Table'[Customer Number] ),
                'Table'[Transaction Date] <= SELECTEDVALUE ( 'Date'[Date] )
            )
        )
    )
RETURN
    VAR _table2 =
        ADDCOLUMNS (
            _table,
            "Tag", IF ( [_lastdate] = [Transaction Date] && [Description] = "OPEN", 1, 0 )
        )
    RETURN
        SUMX ( _table2, [Tag] )
count of CLOSED = 
VAR _table =
    ADDCOLUMNS (
        'Table',
        "_lastdate", CALCULATE (
            MAX ( 'Table'[Transaction Date] ),
            FILTER (
                ALLEXCEPT ( 'Table', 'Table'[Customer Number] ),
                'Table'[Transaction Date] <= SELECTEDVALUE ( 'Date'[Date] )
            )
        )
    )
RETURN
    VAR _table2 =
        ADDCOLUMNS (
            _table,
            "Tag", IF ( [_lastdate] = [Transaction Date] && [Description] = "CLOSED", 1, 0 )
        )
    RETURN
        SUMX ( _table2, [Tag] )

Result:

4.JPG5.JPG

 

Best Regards,

Lin

 

 

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Sorry for the delay, I did not receive a notification.

 

This is very, very close.

For whatever reason, when I select the date it only shows open/closed for that date only. 

 

I've triple checked my math and formulas, but it's not aggregating all the customer numbers that are open and closed status for the given date.

hi, @Anonymous 

I have tested on my sample pbix file, it works well.

If possible, please share your simple sample pbix file with your expected output for us have a test.

You can upload it to OneDrive and post the link here. Do mask sensitive data before uploading.

 

 

Best Regards,

Lin

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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Kudoed Authors