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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
userdata
Helper IV
Helper IV

Calculated measure to get if current month is june, not working correctly

Hi,

 

I have a question regarding a measure that is not working properly.What i want to achieve is if current month is jan, feb or march, then do sum( sales1a and sum of sales1b), if current month falls under month april, may, june then use sales2, but for some reason the measure is not working. This is what I have :  

 

IF(MONTH(today())= 1 ,([sales1a]+[sales 1b]),
IF(MONTH(TODAY())=2,([sales1a]+[sales1b]),if(MONTH(TODAY())= 3 ,([sales1a]+[sales1b]),
if(MONTH(TODAY())=4, ([sales2a]+[sales2b]),if(MONTH(TODAY())=5, ([sales2a]+[sales2b]),if(MONTH(TODAY())=6, ([sales2a]+[sales2b]),0)))
 
 
The measure itself doesnt give any errors but the issue is when i test it and drag all months in there , it does give me values for every month, but the issue is if we the current month is feb, then it should calculate sales1a and sales1b, but as current month is not jan or june or july etc, it should give a 0. For some reason when i have month, year and the measure in the table, it does also give values where the current month is not in that specific month. It should give me only values if icurrent month is eg. feb, but should give a 0 for all the other months.
Thanks!
3 REPLIES 3
userdata
Helper IV
Helper IV

userdata_0-1621874286277.png

if you see measure 2, doesnt add up for some reason sales 1a and sales 1b and second it gives values, although it should only give values when current month falls under one of those months. 

 

amitchandak
Super User
Super User

@userdata , Try a measure like

 

Switch(True(),
MONTH(today()) <4, ([sales1a]+[sales 1b]) ,
MONTH(today()) <7, ([sales2a]+[sales2b])
)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thanks for the reply but that wont solve it because the issue is that it will calculate sales 1a and 1b only if its bigger than.It gives me the same values as the above formula.  The thing I want to achieve is if current month falls under month 1,2 or 3, then do sales1a and sales1b, if current month falls under month 4,5,6 then do sales2a and sales2b, otherwise 0 . I tried an or function but that gave me errors. I think maybe I have to define curren month differently? 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.