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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Niiru1
Helper V
Helper V

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors