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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
LucMarv
Helper I
Helper I

DAX IF statement, cannot convert type

Hi,

I have the following measure, which creates a natural sentence, which I then put on a hover page, to show up when a user hovers over the individual bars of a barchart.

 

Overview_hover_txt = 

var TvsP = IF(SELECTEDVALUE(Overview_MostRecentYR[Diagnoses]) = SELECTEDVALUE(Overview_MostRecentYR[PersonsWithDx]), 
                    "", 
                    " ("&&format(SELECTEDVALUE(Overview_MostRecentYR[Diagnoses]), "#,#")&" tumours)"
            )


RETURN

"In "&max(Overview_MostRecentYR[year])&", "&format(sum(Overview_MostRecentYR[PersonsWithDx]), "#,#")&" Victorians were diagnosed with "&SELECTEDVALUE(TumourGrouping[SumPage_LvL1_label], "cancer")&TvsP&". Our most recent data shows that 5-year survival is "&format(sum(Overview_MostRecentYR[Survival]), "#.#%")&" (95% confidence interval "&format(SELECTEDVALUE(Overview_MostRecentYR[Survival_LL]), "#.#%")&"-"&format(SELECTEDVALUE(Overview_MostRecentYR[Survival_LL]), "#.#%")&" for the period "&SELECTEDVALUE(Overview_MostRecentYR[Period])&"). In "&max(Overview_MostRecentYR[year])&", "&format(sum(Overview_MostRecentYR[Deaths]), "#,#")&" Victorians died from "&SELECTEDVALUE(TumourGrouping[SumPage_LvL1_label], "cancer")&"."

 

It works where the condition is met (i.e. the IF statement returns ""):

LucMarv_1-1643341925267.png

 

 

, but I get an error when the condition is not met. The error is:

LucMarv_0-1643341838637.png

 

What can I do to let the if statement return 

 

" ("&&format(SELECTEDVALUE(Overview_MostRecentYR[Diagnoses]), "#,#")&" tumours)"
 
 
I tried 
CALCULATE(" ("&&format(SELECTEDVALUE(Overview_MostRecentYR[Diagnoses]), "#,#")&" tumours)")
but this was more out of desparation...
1 ACCEPTED SOLUTION
VijayP
Super User
Super User

@LucMarv 
Need to unders why "&&" in the below line (Value for False Condition) . I think this is causing problem

("&&format(SELECTEDVALUE(Overview_MostRecentYR[Diagnoses]), "#,#")&" tumours)

 




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


View solution in original post

2 REPLIES 2
LucMarv
Helper I
Helper I

Yep that was it! Too bad PowerBI does not give an informative error message when this happens! 

Thanks for taking the time to help me! Much appreciated!

VijayP
Super User
Super User

@LucMarv 
Need to unders why "&&" in the below line (Value for False Condition) . I think this is causing problem

("&&format(SELECTEDVALUE(Overview_MostRecentYR[Diagnoses]), "#,#")&" tumours)

 




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

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.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.