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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Lolo_2023
Frequent Visitor

Current month and previous month on line chart for selected month

 Hi everyone,

 

i had a measure to calculate the previous month data, it didn't showing on line chart but it's working on card.

pic1.png

 

what i really want is, when I choose Feb on month slicer, it's show the data for feb and jan 

 

this is my data table

pic2.png

3 REPLIES 3
tharunkumarRTK
Solution Sage
Solution Sage

I think you forgot put your measure definition, there are many ways to do this. Here is one


Var selectedmonth = selectedvalue(Table[MonthNum))
Var prevMonth = selectedmonth - 1
Var last2months =treatas( {prevmonth, selectedmonth}, Table[MonthNum])
Var result = calculate([Measure], keepfilters(last2months))
return result 


If the post helps please give a thumbs up


If it solves your issue, please accept it as the solution to help the other members find it more quickly.


Tharun



It works with me , after adding the variable in the beginning 

LastMonthValue = Var selectedmonth = selectedvalue(Table1[Month])

Var prevMonth = selectedmonth - 1

Var last2months =treatas( {prevmonth, selectedmonth}, Table1[Month])

Var result = calculate([Last Month], keepfilters(last2months))

return result


but still didn't show on the line graph 

 

pic4.png

pic3.png

 

Error

how can i fix it ?

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.