Forum Discussion

joshua1990's avatar
joshua1990
Post Prodigy
3 years ago
Solved

Measure - Filter based on different table

Hi experts! I have a sales table and an order table. Simple tables that contains article, date and value. Both tables are linked to a calendar table. Sales Article Date Value ...
  • wdx223_Daniel's avatar
    3 years ago

    please try these steps

    1, add a column in the calendar table, Year-Week

    2, create a measure

    =VAR _yw=selectedvalue(orders[Shared Date(Year_Week)])

    VAR _selectedweeks=topn(4,filter(allselected(calendar[year-week]),calendar[year-week]>=_yw),calendar[year-week],ASC)

    return

    calculate(sum(Sales[Value]),treatas(_selectedweeks,calendar[year-week]))

     

  • wdx223_Daniel's avatar
    wdx223_Daniel
    3 years ago

    try these steps

    1, add a new dimension table, say YearWeek, as the slicer table with no relationships.

    YearWeek=Values(orders[Shared Date(Year_Week)])

    2, put the calendar[Year-Week] on the visual, and amend the meausre

    =VAR _yw=selectedvalue(YearWeek[Shared Date(Year_Week)])

    VAR _selectedweeks=topn(4,filter(allselected(calendar[year-week]),calendar[year-week]>=_yw),calendar[year-week],ASC)

    return

    if(max(calendar[year-week]) IN _selectedweeks,sum(Sales[Value]))