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
mvyskala
Helper I
Helper I

Calculating target number based on day in month

Hello,

 

I'd like to in my view calculate column or measure based on which day of month. For example I have target number for year 2017 12.000. If today is day before 16th day in current month, the target should be based on end of previous month, but if the day is 16th or after in current month, target should be based on end of current month.

 

So in this example, if the day is 15th March target should be 2.000 (target for February), if the day is 16th March, target should be 3.000.

 

Any idea how to do this without using to many IF functions?

Thanks in advance

MV

1 ACCEPTED SOLUTION
Phil_Seamark
Employee
Employee

Hi @mvyskala

 

What happens if you add this calcuated column to your table?

 

Target = (12000 / 12 ) *  (MONTH('Table'[your date col]) + IF(DAY([your date col])>=16,1,0))

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

5 REPLIES 5

Hi @mvyskala,

 

IF is certainly the easiest way to do this, it shouldn't be a very long formula either. Something like below should work for you. Is there any reason you're wanting to avoid IF statements?

 

=
IF (
    DAY ( TODAY () ) <= 16,
    CALCULATE ( [Sum of Target], PREVIOUSMONTH ( 'Date Table'[Date] ) ),
[Sum of Target] )

Best Regards,

Reid Havens - Owner / Founder

Havens Consulting Inc.

Hi @Reid_Havens and @Phil_Seamark, thanks a ton for your swift reply. I'll get to this issue in my business hours (CET) and I'll get back to you. Seems like I should be able to find solution from your ideas.

 

Many thanks

MV

Hi @mvyskala,

 

Have you tried the solutions provided above? If you still have any problem, feel free to post here.Smiley Happy

 

If the solutions work for you, could you accept the helpful reply as answer to help others who may have similar issue easily find the answer and close this thread?

 

Regards

Phil_Seamark
Employee
Employee

Hi @mvyskala

 

What happens if you add this calcuated column to your table?

 

Target = (12000 / 12 ) *  (MONTH('Table'[your date col]) + IF(DAY([your date col])>=16,1,0))

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Thanks for all inputs. I did something similar as @Phil_Seamark offered. My final solution was basically something like this

 

Target = (([EndOfFiscalYearTarget] / 12 ) *  ((MONTH('Table'[Today]))-3)) + IF([DayToday]>16;([EndOfFiscalYearTarget]/12);0)

 

I've creared column for Today and for Today.[Day] and I'm also offsetting 3 months because of start of fiscal year.

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.