cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Show data on line chart based on Period

Hi all,

 

I have a table contain Time  column (drill down by hour) and count column.

1.png

 
 

The data I try to show in line chart have a slicer called period (Hourly, Daily, Monthly, Weekly, Yearly)

 

Annotation 2020-02-27 135536.png

 

Can I choose the value on Period and the chart will reflect the period?

Any help is appreciated.

 

Thank you.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Show data on line chart based on Period

Hi @Thai_Nguyen96

 

You can create a measure below, then drag this measure to the line chart: 

Measure = 
var y= CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date])))) 
var q= CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&QUARTER('Table'[Range Date])=QUARTER(MAX('Table'[Range Date]))))
var m=CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&MONTH('Table'[Range Date])=MONTH(MAX('Table'[Range Date]))))
var w=CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&WEEKNUM('Table'[Range Date])=WEEKNUM(MAX('Table'[Range Date]))))
var h=CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&MONTH('Table'[Range Date])=MONTH(MAX('Table'[Range Date]))&& DAY('Table'[Range Date])=DAY(MAX('Table'[Range Date]))))
var d=CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&MONTH('Table'[Range Date])=MONTH(MAX('Table'[Range Date]))&& DAY('Table'[Range Date])=DAY(MAX('Table'[Range Date]))&&HOUR('Table'[Range Date])=HOUR(MAX('Table'[Range Date]))))
return SWITCH(SELECTEDVALUE('Table (2)'[Period]),"Monthly",m,"Weekly",w,"Yearly",y,"Hourly",h,"Quarterly",q,"Daily",d)

 

q7.PNG

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: Show data on line chart based on Period

Hi @Thai_Nguyen96

 

You can create a measure below, then drag this measure to the line chart: 

Measure = 
var y= CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date])))) 
var q= CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&QUARTER('Table'[Range Date])=QUARTER(MAX('Table'[Range Date]))))
var m=CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&MONTH('Table'[Range Date])=MONTH(MAX('Table'[Range Date]))))
var w=CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&WEEKNUM('Table'[Range Date])=WEEKNUM(MAX('Table'[Range Date]))))
var h=CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&MONTH('Table'[Range Date])=MONTH(MAX('Table'[Range Date]))&& DAY('Table'[Range Date])=DAY(MAX('Table'[Range Date]))))
var d=CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&MONTH('Table'[Range Date])=MONTH(MAX('Table'[Range Date]))&& DAY('Table'[Range Date])=DAY(MAX('Table'[Range Date]))&&HOUR('Table'[Range Date])=HOUR(MAX('Table'[Range Date]))))
return SWITCH(SELECTEDVALUE('Table (2)'[Period]),"Monthly",m,"Weekly",w,"Yearly",y,"Hourly",h,"Quarterly",q,"Daily",d)

 

q7.PNG

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Super User IV
Super User IV

Re: Show data on line chart based on Period

Refer, if this can Help:

https://community.powerbi.com/t5/Desktop/Slicer-MTD-QTD-YTD-to-filter-dates-using-the-slicer/td-p/50...



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors