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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.