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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Paulo123
Frequent Visitor

variation

I wanted to calculate the monthly change from the current month to the previous month. but I want it to display the results only when I select the month filter.

2 ACCEPTED SOLUTIONS
ValtteriN
Super User
Super User

Hi,

You can use ISFILTERED or HASONEFILTER to check if a slicer is applied and then use this in IF condition. 

e.g.
DAX:

LM IF FILTERED = IF(HASONEFILTER('Calendar'[Today].[Month]),
CALCULATE('Matrix example'[Measure 6],DATEADD('Calendar'[Date],-1,MONTH)),
BLANK())
 
End result (with and without filter):
ValtteriN_0-1642529460982.png

 

ValtteriN_1-1642529476313.png

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!







Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

I adapted the answer to my need

 

 

VAR MES% = if(HASONEFILTER(CALENDARIO[Date].[Mês]),
VAR _MES_ANTERIOR=CALCULATE(Dados[SOMA_E],DATEADD(CALENDARIO[Date],-1,MONTH))
RETURN
DIVIDE(Dados[SOMA_E] - _MES_ANTERIOR,_MES_ANTERIOR))

View solution in original post

2 REPLIES 2
ValtteriN
Super User
Super User

Hi,

You can use ISFILTERED or HASONEFILTER to check if a slicer is applied and then use this in IF condition. 

e.g.
DAX:

LM IF FILTERED = IF(HASONEFILTER('Calendar'[Today].[Month]),
CALCULATE('Matrix example'[Measure 6],DATEADD('Calendar'[Date],-1,MONTH)),
BLANK())
 
End result (with and without filter):
ValtteriN_0-1642529460982.png

 

ValtteriN_1-1642529476313.png

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!







Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I adapted the answer to my need

 

 

VAR MES% = if(HASONEFILTER(CALENDARIO[Date].[Mês]),
VAR _MES_ANTERIOR=CALCULATE(Dados[SOMA_E],DATEADD(CALENDARIO[Date],-1,MONTH))
RETURN
DIVIDE(Dados[SOMA_E] - _MES_ANTERIOR,_MES_ANTERIOR))

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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