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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
GThurairajah
Regular Visitor

Creating a DAX calculation to create a Trend series Graph

Hello I have the following problem

 

I have a pre-established Report with close to 50 different elements that are filtered at Page / Report level. The Report is designed to look at 1 days worth of information. Now I need to add a Trend series graph that operates independently of the page level filter preferably through a DAX calculation where it would create a graph by day for the past 28 days. That way I would have my existing report operate on a page daily filter level and a DAX calculation to return trendseries on multiple dates. 

 

_Please let me know if this is possible


Thanks

-Gaj

1 ACCEPTED SOLUTION

Hey,

 

if the answer solves your problem, mark the answer as solution, this will also help others.

 

Regards

 

If you find the solution, the explanation or something else special, do not hesitate to kudo the answer, in appreciation for the effort it takes to provide an answer that solves your issue 😉



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

7 REPLIES 7
TomMartens
Super User
Super User

Hey,

 

you can use a measure like this

Measure = 
var selectedDate = CALCULATE(MAX('Calendar'[Date]))
var startDate = selectedDate - 28
var daterange = DATESBETWEEN('Calendar'[Date],startdate, selectedDate)
return
CALCULATE(
	SUM('FactWithDates'[Amount])
	,daterange
)


Assumptions about this measure

  • there is a separate date table available (in my example this table is called "Calendar"
  • there is an active relationship defined in the model on the one-side (Calendar) on the many-side (theFacttable)

The Measure works like this

  • the selected date is stored in the variable "selectedDate"
  • the startdate of the timeframe is stored in the variable startDate
  • the daterange is stored in the variable "daterange" (this variable now contains a table with the dates of the daterange)
  • Finally the measure is calculated expanding the exisiting filtercontext from the selected date to the daterange

Here is a little example of the outcome of this measure

daterange.png

 

Hope this gets you started

 

Regards



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Worked perfectly appreciate the help

Hey,

 

if the answer solves your problem, mark the answer as solution, this will also help others.

 

Regards

 

If you find the solution, the explanation or something else special, do not hesitate to kudo the answer, in appreciation for the effort it takes to provide an answer that solves your issue 😉



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

Hi Tom,

 

I have a similar requirement but i need to show the trend for completed 3 Week/Months/ Quarters instead on Days. I have a Month/Quarter/ Week filter on the top ..is it possible to show the trend based on completed  periods instead on days??

 

Thanks & Regards,

Rajeev Bikkani

Hey Rajeev,

 

I will give this a closer look this evening (my time 🙂 ).

 

Can you please provide a link a pbix file, that contains sample data that enables us/me to answer your question more quickly.

Upload your file to OneDrive or Dropbox and than share a public accessible link.

 

Regards Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

 

Hello I have the following problem

 

I have a pre-established Report with close to 50 different elements that are filtered at Page / Report level. The Report is designed to look at 1 days worth of information. Now I need to add a Trend series graph that operates independently of the page level filter preferably through a DAX calculation where it would create a graph by day for the past 28 days. That way I would have my existing report operate on a page daily filter level and a DAX calculation to return trendseries on multiple dates. 

 

_Please let me know if this is possible


Thanks

-Gaj

Hmm,

 

to me this seems to be the exact the question I tried to answer here

https://community.powerbi.com/t5/Desktop/Creating-a-DAX-calculation-to-create-a-Trend-series-Graph/m...

besides the title of the post, if I'm wrong please correct me, if I'm right use the above mentionen link. For additional input, comments, and better solutions 😉

 

Regards



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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