Forum Discussion

lherbert501's avatar
lherbert501
Icon for Post Prodigy rankPost Prodigy
3 years ago

Prev Month Sales Not displaying

Hi, 

 

I have a measure below which needs to say if the value of sales = 0 on the first day of the month, then move to the next day which is greater than 0.

 

This dax works when I apply it to the 1st of the current reporting month measure, but as soon as I put a +1 on this query it returns as below.

I can't work out why it wont show 202302 with the value. Could somebody please help? 

 

 

Prev Month =

VAR __prevMonthDay =
    EOMONTH ( MAX ( RS_Dates[DateFull] ), -2 ) + 1
VAR __PrevMonthWorkingDay =
    CALCULATE (
        MIN ( RS_Dates[DateFull] ),
        REMOVEFILTERS ( RS_Dates[DateFull] ),
        RS_Dates[DateFull] >= __prevMonthDay,
        RS_Dates[IsWorkingDay] = TRUE ()
    )
RETURN
   if(
        CALCULATE( [Total Sales], Sales[Date Added] = __PrevMonthWorkingDay ) =0 ,
     CALCULATE( [Total Sales], Sales[Date Added] = __PrevMonthWorkingDay+1))

2 Replies

  • lherbert501 , if you have a date with help from the date table and time intelligence have measures like 

     

    MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
    last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
    last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
    MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
    last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
    last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))

     

    Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
    https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5bd4
    To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

    • lherbert501's avatar
      lherbert501
      Icon for Post Prodigy rankPost Prodigy

      Hi amitchandak ,

       

      But how would this help me find the first day of the previous month sales where its not 0 or is a working day?

       

      The query is essentially 

      CALCULATE( [Total Sales], Sales[Date Added] = __PrevMonthWorkingDay ) 

      but its returning 0 and I can't seem to get around it to move to the next day with a value

       

      Thanks