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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Crossjoin measure with filter and subtracton

I have a measure that counts number of working days in the month[Measure 5].

 

What I want to do is subtract the [Rules] values from this e.g. 23 working days - 2.5 days according to the IF statement in rules calculation

 

My DAX is:

Measure 7 = 
CALCULATE
(
CALCULATE(
countx(
SUMMARIZE(
CROSSJOIN('Employee Absence Full Table','DimDate','Query1'),
'Employee Absence Full Table'[PERSON_ID],'DimDate'[Date],'Query1'[Rules]),'DimDate'[Date]),
FILTER(DimDate,DimDate[WorkingDays] <>BLANK())
)
-COUNTX('Query1','Query1'[Rules])
)

CrossJoin table 1.PNG

 

However when I run my Measure 7 DAX I get (23-1) not 2.5:

CrossJoin table 2.PNG

Is there a way to select the individual values in [Rules] and subtract them from a measure?

 

Thanks

2 REPLIES 2
wdx223_Daniel
Super User
Super User

Measure 7 =
CALCULATE (
    COUNTX (
        SUMMARIZE (
            CROSSJOIN (
                'Employee Absence Full Table',
                FILTER ( DimDate, DimDate[WorkingDays] <> BLANK () ),
                'Query1'
            ),
            'Employee Absence Full Table'[PERSON_ID],
            'DimDate'[Date],
            'Query1'[Rules]
        ),
        'DimDate'[Date]
    ),
    - COUNTX ( 'Query1', 'Query1'[Rules] )
)
)
lbendlin
Super User
Super User

Can you please explain the reasoning for using nested CALCULATE and for including the rules table in the Crossjoin?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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