Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
sash
Frequent Visitor

Showing current day value and value one week ago on same chart

Hi, 

 

I'd like to show a chart for the last 7 days and show 2 values for each day: current day and value one week ago. The source of the data is a star-modelled data warehouse with a fact table and a related date dimension.

 

Seems like a simple request, but I'm stuck.

 

Here are my measures: 

 

 

Today = DATE(YEAR(NOW()); MONTH(NOW()); DAY(NOW()))

DayDiff = 
SWITCH (
    TRUE ();
    dim_Date[Today] < dim_Date[Date]; -1 * DATEDIFF (dim_Date[Today]; dim_Date[Date]; DAY);
    dim_Date[Today] > dim_Date[Date]; DATEDIFF (dim_Date[Date]; dim_Date[Today]; DAY);  
    0
)

Last7Days = IF(dim_Date[DayDiff]<7 && dim_Date[DayDiff]>=0; TRUE(); FALSE()) 

Impressions = SUM('fact_TweetEngagement'[ImpressionsDiff])

ImpressionsPW = 
CALCULATE(
    fact_TweetEngagement[Impressions];
    DATEADD(dim_Date[Date]; -7; DAY)
)

 

 

I added a bar-chart. To show only last 7 days I set the visual filter to Last7Days=TRUE. I added Impressions and ImpressionsPW measure. The chart shows Impressions measure, but not ImpressionsPW. It seems that the visual filter affects the ImpressionsPW measure so the measure is not returning any values.

 

Here's an example of a modified chart showing last 2 weeks:

 

powerbi_chart.png 

As you can see the ImpressionsPW value is not returning values for dates older than 1 week, because it's out of the visual filter context (7+7...).

 

What am I doing wrong?

 

1 REPLY 1
v-micsh-msft
Microsoft Employee
Microsoft Employee

Hi sash,

 

I think the impressionSPW not showing the earlier week data should be caused the the DATEADD function.

By the way, could you please share some data sample so that we could build some texts based on that?

In addition, regarding showing the last 7 days, check the reply from smoupre:

Can I set page filters for "last 7 days"?

Regards

 

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.