Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Hiding Future dates in line Graph

Hi Experts

 

I am trying not to plot future values as into my line graph as i get zero on the line plot as i have no data for those dates. When i use the following DAX

CurrentYear =
VAR CurrentYearSales =
CALCULATE ( SUM ( 'Test Data_'[cr03a_reportscrimemade] ), 'Test Data_'[IsCurrentYear] = TRUE () )
RETURN
IF ( CurrentYearSales = BLANK (), 0, CurrentYearSales )
 
However, if i amend my DAX too
CurrentYear =
VAR CurrentYearSales =
CALCULATE ( SUM ( 'Test Data_'[cr03a_reportscrimemade] ), 'Test Data_'[IsCurrentYear] = TRUE (),
FILTER(
ALLSELECTED( 'Test Data_'),
[cr03a_period] <=TODAY()
)
)
RETURN
IF ( CurrentYearSales = BLANK (), 0, CurrentYearSales )
 
I get a constant line showing the previous month value 
 
I want the merasure to plot only two data point Jan 21 and Feb 21 as i only have data for those month so far...

 

  • Hi Anonymous 

     

    Download sample PBIX with data and charts

     

    If you could supply some data that would help understand what you are working with.  

    You say you have no data for March onwards.  Do you mean you have rows with dates for March but no sales values in those rows?  Or you actually have no rows for any date after the end of Feb?

     

    To plot Sales up to the current month use this measure

     

    Sales Up to This Month = CALCULATE(SUM(Table1[Sales]), FILTER('Table1', MONTH('Table1'[Date]) <= MONTH(TODAY())))

     

     

     

    To plot data up to the previous month use this measure

     

    Sales Up to Last Month = CALCULATE(SUM(Table1[Sales]), FILTER('Table1', MONTH('Table1'[Date]) <= MONTH(TODAY()) - 1 ))
    

     

     

    Regards

    Phi

2 Replies

  • Hi Anonymous 

     

    Download sample PBIX with data and charts

     

    If you could supply some data that would help understand what you are working with.  

    You say you have no data for March onwards.  Do you mean you have rows with dates for March but no sales values in those rows?  Or you actually have no rows for any date after the end of Feb?

     

    To plot Sales up to the current month use this measure

     

    Sales Up to This Month = CALCULATE(SUM(Table1[Sales]), FILTER('Table1', MONTH('Table1'[Date]) <= MONTH(TODAY())))

     

     

     

    To plot data up to the previous month use this measure

     

    Sales Up to Last Month = CALCULATE(SUM(Table1[Sales]), FILTER('Table1', MONTH('Table1'[Date]) <= MONTH(TODAY()) - 1 ))
    

     

     

    Regards

    Phi