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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Convert if statement to value

Hello, 

Is tehere a way how to convert returned value from if statement into number? 

In IMG (Column 2G_5RDC-TA)  is visible that power bi does not sum returned value and treat them as string. 

My formula is:

2G_5RDC-TA =
IF("5RDC" IN VALUES(Load_data_merged[Sufix_template.FDP]),
IF("TA" IN VALUES(Load_data_merged[Sufix_template.FDP]),1,""))
 
and format is whole number. I am about to use value for converting, but need your help. 
Thank you  
convert to number.png

 

1 ACCEPTED SOLUTION
v-kkf-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try the following formula:

 

2G_5RDC-TA = 
SUMX (
    SUMMARIZE (
        Load_data_merged,
        Load_data_merged[Load number],
        "result",
            IF (
                "5RDC" IN VALUES ( Load_data_merged[Sufix_template.FDP] ),
                IF ( "TA" IN VALUES ( Load_data_merged[Sufix_template.FDP] ), 1, "" )
            )
    ),
    [result]
)

vkkfmsft_0-1643093907843.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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

5 REPLIES 5
v-kkf-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try the following formula:

 

2G_5RDC-TA = 
SUMX (
    SUMMARIZE (
        Load_data_merged,
        Load_data_merged[Load number],
        "result",
            IF (
                "5RDC" IN VALUES ( Load_data_merged[Sufix_template.FDP] ),
                IF ( "TA" IN VALUES ( Load_data_merged[Sufix_template.FDP] ), 1, "" )
            )
    ),
    [result]
)

vkkfmsft_0-1643093907843.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Anonymous
Not applicable

Thanks a million

VahidDM
Super User
Super User

Hi @Anonymous 

 

It's a total issue, very common. See this link to find out why it's wrong and how to fix it:

 

https://www.vahiddm.com/post/why-my-measure-returns-the-wrong-total 

 

You can change "" to blank() in your formula.

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

ValtteriN
Super User
Super User

Hi,

If you are referring to the total column the problem is not actually with aggregation. Total row uses the same logic as the column it counts the total from so in this case your total row tests what this dax returns:

2G_5RDC-TA =
IF("5RDC" IN VALUES(Load_data_merged[Sufix_template.FDP]),
IF("TA" IN VALUES(Load_data_merged[Sufix_template.FDP]),1,""))
 
Since the result is 1 the total is 1. To circumvent this you can use IF(SELECTEDVALUE(table[load_number])=blank(),CALCULATE([2G_5RDC-TA],all(table)),[2G_5RDC-TA]))

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!






Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Thank you ValtteriN, 

Unfortunately this workaround does not helped me.

Yes, you are right. I am referncing to total. In your solution is refrence to loadnumber. Hovewer this field is never empty.

 

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.