Forum Discussion

lennelei's avatar
lennelei
Regular Visitor
8 months ago
Solved

Help with DAX for Matrix Visual - Filtering Previous Weeks

Despite extensive research, I'm stuck on some details regarding how to display data for previous weeks after selecting a single week in a slicer. I have found solutions that work well for a Column C...
  • lennelei's avatar
    8 months ago

    Gemini 3 came to my rescue ๐Ÿ™‚

    First of all, it gave me a correct measure for me to achive what I was looking for in a matrix:

    Measure val S-3 to S v2 = 
    VAR WeekRank
    = MAX(date_picker[rank])
    VAR MinRank = WeekRank - 3
    VAR MaxRank = WeekRank
    VAR MinContext = MIN(time[rank])
    VAR MaxContext = MAX(time[rank])
    VAR IsInWindow = MinContext <= MaxRank && MaxContext >= MinRank

    VAR Result
    = CALCULATE([Measure val],time[rank] >= MinRank,time[rank] <= MaxRank)

    RETURN IF(IsInWindow,
            COALESCE(Result, 0),
            BLANK()
    )

    But more important, it introduced me to the Calculation Groups in Power BI which is a killer feature for my needs as I'll be able to define this calculation method once and reuse it with multiple measures.