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

Dax formula that does not filter on calender table

I need to know how my DAX formula called "Fakturert" needs to be updated to filter on dimKalender. 

 

I have 3 tables 

Rune__0-1696322504743.png

Relationship between 
JobTask[Job No_] -->[JobLedgerEntry[Job No_]
dimKalender[Date] -->[JobLedgerEntry[Posting Date]

 

In Power Bi report view in my table where I use JobTask[Job No_] 

When I use dimKalender for filter it only filters correctly for one of my DAX formulas. 

 

Rune__1-1696322889781.png

Incorrectly for this Dax
Fakturert =
SUMX(
    FILTER(
        JobTask,
        JobTask[Job Task Type] = 4
    ),
    CALCULATE(
        SUM(JobLedgerEntry[Line Amount (LCY)]),
        FILTER(
            ALL(JobLedgerEntry),
            JobLedgerEntry[Job No_] = EARLIER(JobTask[Job No_]) &&
            JobLedgerEntry[Job Task No_] >= EARLIER(JobTask[Totaling.1]) &&
            JobLedgerEntry[Job Task No_] <= EARLIER(JobTask[Totaling.2]) &&
            JobLedgerEntry[Source Code] = "SALG"
        )
    )
)
 
Correct for this DAX
FakturertLinje =
VAR SelectedJobNo = SELECTEDVALUE(JobTask[Job No_])
VAR SelectedJobTaskNo = SELECTEDVALUE(JobTask[Job Task No_])

RETURN
CALCULATE(
        SUMX(
        FILTER(
            JobLedgerEntry,
            JobLedgerEntry[Job No_] = SelectedJobNo &&
            JobLedgerEntry[Job Task No_] = SelectedJobTaskNo &&
            JobLedgerEntry[Source Code] = "SALG"
        ),
        JobLedgerEntry[Line Amount (LCY)]
        )
    )
 Dataset
1 ACCEPTED SOLUTION
Rune_
Frequent Visitor

Solutions

Fakturert =
-SUMX(
    FILTER(
        JobTask,
        JobTask[Job Task Type] = 4
    ),
    CALCULATE(
        SUM(JobLedgerEntry[Line Amount (LCY)]),
        FILTER(SUMMARIZE(
            JobLedgerEntry,
            JobLedgerEntry[Job No_],
            JobLedgerEntry[Job Task No_],
            JobLedgerEntry[Posting Date],
            JobLedgerEntry[Source Code]
        ),
            JobLedgerEntry[Job No_] = EARLIER(JobTask[Job No_]) &&
            JobLedgerEntry[Job Task No_] >= EARLIER(JobTask[Totaling.1]) &&
            JobLedgerEntry[Job Task No_] <= EARLIER(JobTask[Totaling.2]) &&
            JobLedgerEntry[Source Code] = "SALG"
        )
    )
)

View solution in original post

1 REPLY 1
Rune_
Frequent Visitor

Solutions

Fakturert =
-SUMX(
    FILTER(
        JobTask,
        JobTask[Job Task Type] = 4
    ),
    CALCULATE(
        SUM(JobLedgerEntry[Line Amount (LCY)]),
        FILTER(SUMMARIZE(
            JobLedgerEntry,
            JobLedgerEntry[Job No_],
            JobLedgerEntry[Job Task No_],
            JobLedgerEntry[Posting Date],
            JobLedgerEntry[Source Code]
        ),
            JobLedgerEntry[Job No_] = EARLIER(JobTask[Job No_]) &&
            JobLedgerEntry[Job Task No_] >= EARLIER(JobTask[Totaling.1]) &&
            JobLedgerEntry[Job Task No_] <= EARLIER(JobTask[Totaling.2]) &&
            JobLedgerEntry[Source Code] = "SALG"
        )
    )
)

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