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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors