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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
MarceloDF
Helper I
Helper I

Searching data in common from two list

Hi everyone,
I have a question.

I have this fact Table that is about memberships from a gym.

CustomerStart DateEnd Date
101/03/202328/02/2024
201/04/202331/03/2024
301/05/202330/04/2024
415/06/202330/06/2023

 

So, what I need to do is (the customer will choose from a slicer 1 complete month/year, eg: March 2023.) to count how many customers (with distinctcount) are active in the month that I choose.


But not to check only the month, because the membership can be only 2 weeks. I need to check every date that the customer select (from 1/3 to 31/3) and check if one of those 31 dates fit between Start and End Date.

 

So if the customer choose March/23, the answer is only 1, if the customer choose April/23, the answer is 2, in May/23 is 3 and so on.

 

Hope that understood what I need. 

 

Thank you.

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
https://1drv.ms/u/s!AiUZ0Ws7G26RhzRl8052qJ9QGeVp?e=Vhf0Px

Screen Capture #905.png

View solution in original post

7 REPLIES 7
MarceloDF
Helper I
Helper I

I was using different fields for the customer... thank you Ahmed for the solution!

MarceDF
Frequent Visitor

Hi @Ahmedx , look what I receive.

 

MarceDF_0-1681987510150.png

This is the measure with the changes:

Active Members History =


VAR _Date =
    VALUES ( dimDates[Date] )
VAR _tbl1 =
    SELECTCOLUMNS (
        GENERATE (
            'factCustomerHistoryHistory',
            DATESBETWEEN ( 'dimDates'[Date], 'factCustomerHistoryHistory'[Start_Date], 'factCustomerHistoryHistory'[End_Date] )
        ),
        "@Customer", [Customer ID],
        "@Date", [Date]
    )
VAR _tbl2 =
    GENERATE ( VALUES ( 'factCustomerHistoryHistory'[Customer] ), _Date )
RETURN
    CALCULATE ( DISTINCTCOUNT ( 'factCustomerHistoryHistory'[Customer] ), INTERSECT ( _tbl2, _tbl1 ) )


What do you think it is?

it says that it is not possible to align text with a number. I don't know the reasons for this, you could not give a link to your file to see

Ahmedx
Super User
Super User

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
https://1drv.ms/u/s!AiUZ0Ws7G26RhzRl8052qJ9QGeVp?e=Vhf0Px

Screen Capture #905.png

MarceDF
Frequent Visitor

I sign in with my personal user.

@Ahmedx or maybe something like this.

 

CALCULATE ( [Distinct Count Customers]
        , NOT ( ISBLANK ( [INTERSECTION of 2 date lists] ) )
)

 

I don't know.

Hi @Ahmedx , thanks for the reply.

 

I don't understand how this is going to help. What I see in those topics, is to count how many dates are in both list.

 

What I need is something like this:

CALCULATE ( [Distinct Count Customers]
        , [one of the dates in the List of the dates selected from dimDates]
          in
         [List of Dates between Start Date and End_Date]
)

 

[one of the dates in the List of the dates selected from dimDates]: This list is going to be all the dates between 1st and 31st of March 2023

 

[List of Dates between Start Date and End_Date]: This list is going to be for each line from the fact that I wrote above.

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.