cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TaroGulati
Helper I
Helper I

If condition issue

Hello everyone,

 

I am having some difficulty of If condition result.

 

I have created this measure : 

Value condition =
var slicerdate = SELECTEDVALUE(Sheet2[Date])
var cal = IF(slicerdate >=TODAY(), [Value Measure],[value +10 measure])
return cal
 
i am trying to present if selected month is less then today then "value +10 measure" other wise "value measure".

Value Measure = SUM(Sheet2[Value])
 
value +10 measure = SUM(Sheet2[Value +10])
 
 
results are not as per value condition measure. 
 
PBI file is on this link:
 
I am missing something in the if expression?
 
thanks in advance for any suggestion. 
2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@TaroGulati , Try like

 

Value condition = 
var slicerdate = maxx(ALLSELECTED(Sheet2), Sheet2[Date])
var cal = IF(slicerdate >TODAY(), sum(Sheet2[Value]),sum(Sheet2[Value +10]))
return  cal
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!
!! Subscribe to my youtube Channel !!

View solution in original post

v-yalanwu-msft
Community Support
Community Support

Hi, @TaroGulati ;

Because your slicer is [month name] ,and your measure is SELECTEDVALUE(Sheet2[Date]) ; so it not right. you could modify the measure as follows:

Value condition = 
var cal = IF(MONTH(SELECTEDVALUE('Sheet2'[month name])&" 1") >=MONTH(TODAY()), [Value Measure],[value +10 measure])
return cal

The final output is shown below:

vyalanwumsft_0-1632115731804.pngvyalanwumsft_1-1632115750650.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yalanwu-msft
Community Support
Community Support

Hi, @TaroGulati ;

Because your slicer is [month name] ,and your measure is SELECTEDVALUE(Sheet2[Date]) ; so it not right. you could modify the measure as follows:

Value condition = 
var cal = IF(MONTH(SELECTEDVALUE('Sheet2'[month name])&" 1") >=MONTH(TODAY()), [Value Measure],[value +10 measure])
return cal

The final output is shown below:

vyalanwumsft_0-1632115731804.pngvyalanwumsft_1-1632115750650.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@TaroGulati , Try like

 

Value condition = 
var slicerdate = maxx(ALLSELECTED(Sheet2), Sheet2[Date])
var cal = IF(slicerdate >TODAY(), sum(Sheet2[Value]),sum(Sheet2[Value +10]))
return  cal
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!
!! Subscribe to my youtube Channel !!
misaki233
Helper II
Helper II

Hi @TaroGulati 

 

You have used SELECTEDVALUE(Sheet2[Date]) to compare with TODAY(), but your slicer is limited by month. You could create a new measure with SELECTEDVALUE(Sheet2[Date]) and you will find it returns BLANK

 Your slicer needs to be accurate to days, or use months in conditions for comparison. It is also possible to get the maximum/minimum date of the selected month and compare it to today. Anyway, you need uniform units of comparison.

 

Helpful resources

Announcements
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

Power BI Dev Camp Session 22 with aka link 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!