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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
lherbert501
Helper V
Helper V

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? 

 

lherbert501_1-1680522137231.png

 

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 2
amitchandak
Super User
Super User

@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-bd52912a5b...
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.

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

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.