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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Divya_Amar
Frequent Visitor

DAX to check if the month filter passed from the matrix visual = current month

 Hi.

I need help with the following scenario please,

I have a matrix visual with month of the fiscal year as columns.I have to write dax for the logic if month in the matrix is current month do calculation1 and for all the past and future months of the year do calculation2. In the example, If the current in feb, for the matrix column Feb,I should display the value of calculation1.For all the other months I should show the value of calculation2. Hope I made th question clear. 

 

Divya_Amar_1-1676499601910.png

 

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Assuming the year and month name have been dragged from the Calendar Table, write this measure

=if(and(today()>=min(calendar[date]),today()<=max(calendar[date])),[measure1],[measure2])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
PawelWrona
Helper III
Helper III

Do you have these months created as text value? If yes, here is the solution:

PawelWrona_0-1676507850722.png


for you specifically it would be:
IF(SELECTEDVALUE('Table'[Month]) = currentMonth, Calculation1, Calculation2)

Thanks Pawel. Will SELECTEDVALUE apply for filtering through matrix visual column? I thought SELECTEDVALUE can only be used for filters applied through FILTERING Pane.Please correct me if I am wrong.

Yes, it will work to get the current value from column or row level as well. Depends how you use it ;⁠)

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.