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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
AndreSchuck
Regular Visitor

Measure that computes the difference of a cumulative fact by day

Hey guys,

 

I have a model to display data from clients' social networks (data from posts on facebook, instagram, etc.). For each social platform, I've a dimension table (that contains basic information of a post, such as created_at date, permalink and so on) and a fact table, that have metrics (such as post impressions, post likes, etc..) with day granularity. The facts in my fact table are all cumulative.

 

I need to create a measure that computes the total impressions by post by a date range (that could be day, month, quarter, or year). In my mind, I was trying to create a measure that can do somenting like:

impressions = (impressions on last day)  - (impressions on (first day - 1 day) )

 

Here is a print of my fact table

AndreSchuck_1-1615994861906.png

 

Can you help my to find a solution for this issue ?

 

Thanks.

 

2 REPLIES 2
amitchandak
Super User
Super User

@AndreSchuck , with help from date table

 

This Day = CALCULATE(sum('Table'[impressions_organic]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))
Last Day = CALCULATE(sum('Table'[impressions_organic]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-1))
Last Day = CALCULATE(sum('Table'[impressions_organic]), previousday('Date'[Date]))

 

both column and measure ways are discussed here

Day Intelligence - Last day, last non continous day
https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c324...

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@amitchandak  Thanks for the replie.

 

The solution do not work. I've forgot to mention that the Most Recent date for each post is not same. I've created this query in Dax Studio to better exemplify what I need (in this case is the ImpressionDifference column, so I can just SUM the Impressions diferrence in order to "unaccumulate" the accumulated facts).

 

Query.png

 

I've not been able to reproduce this query in power bi.

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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