Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Current Week versus Last Week Totals as a Bar Chart

Current Week 1/9/2022 - 1/15/2022 Last Week 1/2/2022 - 1/8/2022   Is it possible to show this as a bar chart ?
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ~

     

    I created a sample:

    Please try these measures:

     

    Current Week = 
    var __Today = TODAY()
    var __WeekStartDate = __Today-WEEKDAY(__Today,1)+1
    var __WeekEndDate = __WeekStartDate+6
    return
    CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),__WeekStartDate<='Table'[Closed] && __WeekEndDate>='Table'[Closed]))

     

     

    Last Week = 
    var __Today = TODAY()
    var __WeekStartDate = __Today-WEEKDAY(__Today,1)-6
    var __WeekEndDate = __WeekStartDate+6
    return
    CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),__WeekStartDate<='Table'[Closed] && __WeekEndDate>='Table'[Closed]))

     

    create a table:

    create a measure:

     

    Measure Value = 
    SWITCH(
    SELECTEDVALUE('Table1'[order]),
    1,[Current Week],
    2,[Last Week]
    )

     

    Finally create a bar chart:

     

    Hope it helps!

     

    Best regards,

    Community Support Team  Gao

    If this post helps, please consider Accept it as the solution to help the other members find it more quickly.