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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Advanced IF function

Hello,

 

I am pretty new in Power BI and I am trying to figure out how can I do my task. I need to write a dax (probably by function IF) where when day of the month is less or equal to 5, I need to add to my price  4% costs, for these 5 days of new month and all previous month. But when day of the month passes 6 and more, I need add to the price 4% only for this new month. No more previous month.

Example: If now is second day of new month, I need + 4% to my price for this new month (2 days) and all days of previous month. If now is 6th day of the new month, I need + 4% to my price only for this month and no more for previous month. 
Can someone help me please? 

This is one of my many attempts, but this is not working properly. Screenshot 2022-10-06 142557.png

Probably, because my condition "|| lastmonth" is everytime fullfiled.
Thanks for your advices
3 REPLIES 3
v-yadongf-msft
Community Support
Community Support

Hi @Anonymous ,

 

It's so strange!

Can you share with me some sample data in table like this?

vyadongfmsft_0-1665137451414.png

 

Best regards,

Yadong Fang

v-yadongf-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try following DAX:

Cost = SWITCH(
    TRUE(),
    MAXX(FILTER('Table','Table'[Month] = MONTH(TODAY())),'Table'[Day])<=5,[VNC+ Import]*1.04,
    'Table'[Month] = MONTH(TODAY()) && MAXX(FILTER('Table','Table1'[Month] = MONTH(TODAY())),'Table'[Day])>6,[VNC+ Import]*1.04
    )

 

I did test in two tables and both worked.

 

Test table 1, until Oct 7th:

vyadongfmsft_0-1665117206465.png

 

Test table 2, until Oct 3rd:

vyadongfmsft_1-1665117298772.png

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hello,

unfortunately, it is not working for me and I do not know why. I tied exactly what you suggested, but no matter what, it is still multypling only this month and all data from previous months just disappear, which is not good. Even when I tied lower numbers of day, it still multiplied only this new month, never last month. todaz.png

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.