Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi all,
please, i would like to compare the sales MTD to the sales same date in last month, and get the result in a card visuel.
for eg, if the current date is 10th january :
Sales MTD = sales from 01 to 10 january (this is ok)
Sales MTD last Month = Sales from 01 to 10 December (this is what i need if possible)
i tested this measure, but it doesn't work exactely on a card vissuel:
Solved! Go to Solution.
Hi, @Sofinobi
May I ask if this is the expected output you are looking for? Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.
Measures:
Sales MTD =
VAR selectedDate =
SELECTEDVALUE ( 'Table'[Date] )
VAR beginningSelectedDate =
EOMONTH ( SelectedDate, -1 ) + 1
VAR _salesMTD =
CALCULATE (
SUM ( 'Sales'[Value] ),
'Sales'[Date] >= beginningSelectedDate
&& 'Sales'[Date] <= selectedDate
)
RETURN
_salesMTD
Sales MTD last Month =
VAR selectedDate =
SELECTEDVALUE ( 'Table'[Date] )
VAR beginningPeriousMonthDate =
EOMONTH ( selectedDate, -2 ) + 1
VAR periousSelectedDate =
EOMONTH ( selectedDate, -2 ) + SELECTEDVALUE ( 'Table'[Date].[Day] )
VAR _salesMTDLastMonth =
CALCULATE (
SUM ( 'Sales'[Value] ),
'Sales'[Date] >= beginningPeriousMonthDate
&& 'Sales'[Date] <= periousSelectedDate
)
RETURN
_salesMTDLastMonth
If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi, @Sofinobi
May I ask if this is the expected output you are looking for? Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.
Measures:
Sales MTD =
VAR selectedDate =
SELECTEDVALUE ( 'Table'[Date] )
VAR beginningSelectedDate =
EOMONTH ( SelectedDate, -1 ) + 1
VAR _salesMTD =
CALCULATE (
SUM ( 'Sales'[Value] ),
'Sales'[Date] >= beginningSelectedDate
&& 'Sales'[Date] <= selectedDate
)
RETURN
_salesMTD
Sales MTD last Month =
VAR selectedDate =
SELECTEDVALUE ( 'Table'[Date] )
VAR beginningPeriousMonthDate =
EOMONTH ( selectedDate, -2 ) + 1
VAR periousSelectedDate =
EOMONTH ( selectedDate, -2 ) + SELECTEDVALUE ( 'Table'[Date].[Day] )
VAR _salesMTDLastMonth =
CALCULATE (
SUM ( 'Sales'[Value] ),
'Sales'[Date] >= beginningPeriousMonthDate
&& 'Sales'[Date] <= periousSelectedDate
)
RETURN
_salesMTDLastMonth
If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
hi, @Sofinobi
try below
sales mtd = totalmtd([salesamount],CALENDRIER[Date])
and
Sales MTD LM = CALCULATE(
[Salesamount],
CALENDRIER[Date]>= eomonth(CALENDRIER[Date]-2)+1,
CALENDRIER[Date]<=edate( CALENDRIER[Date],-1)
)
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello @Sofinobi ,
I have tried with these measures and I have been successful. Try it and let me know if you have been successful
Sales MTD = TOTALMTD(SUM(Sales[sales]), CALENDRIER[Date])
Sales MTD LM= CALCULATE([Sales MTD], DATEADD(CALENDRIER[Date],-1, MONTH))
If it works for you don't forget to mark your comment as a solution 😄
hi @MBernalBI thanks for your answer, but it doesn't work for me, the Sales MTD LM returns the total sales of last month, its not what i need exactely.
thank you again
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
11 | |
10 | |
9 | |
8 |
User | Count |
---|---|
17 | |
12 | |
11 | |
11 | |
11 |