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
SvenJacobs
Frequent Visitor

AND OR in Filter

I have a small issue and do not seem to get the DAX code correct.
 
Need to know the amount of flats occupied.
For this i do a count of contractid and i want to match 2 dates
Date 1 = DatumInHuizing (The date that they start living at us)
Date 2 = DatumUitHuizing (The date that they move out)
So Date 2 can be a date or be empty combining AND and OR gives always errors, the DAX below is without the OR part 😞
 
FlatsBezetPerDatum = CALCULATE(COUNT('Bewoners_Contracten (Sharepoint)'[ContractId]),FILTER('Bewoners_Contracten (Sharepoint)','Bewoners_Contracten (Sharepoint)'[DatumInHuizing]>= FIRSTDATE(DateTable[Date])&&('Bewoners_Contracten (Sharepoint)'[DatumuithuizingZonderNull]<=LASTDATE(DateTable[Date]))))
4 REPLIES 4
v-luwang-msft
Community Support
Community Support

@SvenJacobs ,

Could you  pls share your pbix  and result you want to display ?I need data to test .Remember to remove confident data.

 

Best Regards

Lucien

Fowmy
Super User
Super User

@SvenJacobs 

Please try:

FlatsBezetPerDatum =
VAR __startdate =
    FIRSTDATE ( DateTable[Date] )
VAR __enddate =
    LASTDATE ( DateTable[Date] )
RETURN
    CALCULATE (
        COUNT ( 'Bewoners_Contracten (Sharepoint)'[ContractId] ),
        FILTER (
            'Bewoners_Contracten (Sharepoint)',
            'Bewoners_Contracten (Sharepoint)'[DatumInHuizing] >= __startdate
                && ( 'Bewoners_Contracten (Sharepoint)'[DatumuithuizingZonderNull] <= __enddate )
        ),
        'Bewoners_Contracten (Sharepoint)'[DatumInHuizing] <> BLANK()
    )
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

The 2 DAX codes seem to work only I guess my thinking is not correct..... Why because if I have 100 flats i can not. Need to figure out how your HR thing worked. Because I want to know on a specific date in time the amount of flats that wher rented out.

 

amitchandak
Super User
Super User

@SvenJacobs  Are you trying to find active between the start and end date. Refer to this example

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.