cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Thai_Nguyen96
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
v-qiuyu-msft
Community Support
Community Support

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
amitchandak
Super User
Super User
v-qiuyu-msft
Community Support
Community Support

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.

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.