Forum Discussion

sanderdeweert's avatar
sanderdeweert
Frequent Visitor
1 year ago
Solved

DAX SUMX total not working

This is my measure. I want to be able to filter on the Date dimension. Next I want to get back the latest date before the MAX date of the filted date dimension. This date is used to find the factprog...
  • sanderdeweert's avatar
    sanderdeweert
    1 year ago

    Somehow it works when I put a SUMX in another measure =

    # Prognose opbrengsten V3 =
    SUMX(
        'Job',
        [# Prognose opbrengsten OP]
    )

    This is the original measure
    # Prognose opbrengsten OP =
    VAR max_date = MAX('Date'[Date])
    VAR _dateID =
        CALCULATE(
            MAX(factPrognosisLine[PrognosisDateID]),
            FILTER(
                Prognosis,
                Prognosis[PrognosisFrozen] = "true" &&
                Prognosis[PrognosisDate] <= MAX('Date'[Date])
            ),
            ALL('Date')
        )
    RETURN
    SUMX(
        VALUES(Job),
        CALCULATE(
            factPrognosisLine[PrognosisTotalRevenues_PL],
            FILTER(ALL(factPrognosisLine), factPrognosisLine[PrognosisDateID] = _dateID),
            ALL('Date'),
            FILTER(
                Job,
                Job[PostingDateClosing] > max_date ||
                Job[PostingDateClosing] < DATE(1900, 1, 2)
            )
        )
    )