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
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])
)

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
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.

Top Solution Authors