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
bubblepop
Employee
Employee

For month-to-date, use measure A, otherwise use measure B

There are two measures, A and B, that use different data sources. I want to use these measures in a larger measure, C. In C, I want the logic to be, for the current month (month to date), use measure A, otherwise, use measure B.

 

I know there is MONTH(NOW()) which returns the current month, but I don't know how to use a second variable that keeps track of the month to compare it to this month to date. 

 

So something of the sort for measure C:

IF (var == MONTH(NOW()):

[A]

ELSE

[B]

 

Need help figuring out what to set var to. Measure C will be displayed in a visual card as a numerical value and has a date history, slice-able by month.

3 REPLIES 3
V-lianl-msft
Community Support
Community Support

Based on your description, you need to create a calendar table as a bridge table. Use the date in the calendar table as a condition, and then create an IF statement. See if this works

Ashish_Mathur
Super User
Super User

Hi,

You should ideally build a Calendar Table and from there build 2 slicer visuals - Year and Month name.  Select a certain Year and Month name.  Write this measure

Measure C = if(and(selectedvalue(Calendar[Year])=2021,selectedvalue(Calendar[Month name])=format(today(),"mmmm")),[Measure A],[Measure B])

Hope this helps. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

"I want to use these measures in a larger measure"

That is considered bad practice.  Rather, write each measure individually.

 

Use Calculation Groups for what you are trying to achieve.

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.