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
jimmerph
New Member

Using If Command

I have created a table in power bi and im trying to display how many files are allocated to different people

i have created a new column for the table and used

 

the below returns the amount of files in that name. I am now trying to add another name to this but am unable to work out how this is done without error messaages appearing

 

Any help would be much appreciated

 

Total Files = If(sql view name[column name] = "Joe Bloggs",1,0)
 

 

 

 

6 REPLIES 6
v-juanli-msft
Community Support
Community Support

Hi @jimmerph 

Is this problem sloved? 

If it is sloved, could you kindly accept it as a solution to close this case and help the other members find it more quickly?

If not, please feel free to let me know.

 

Best Regards

Maggie

amitchandak
Super User
Super User

@jimmerph , if you are working in power query/M

try

Total Files = If 'sql view name'[column name] = "Joe Bloggs" then 1 else 0

in dax

Total Files = If('sql view name'[column name] = "Joe Bloggs",1,0)

 

Table name with space can not come like this, select it from the list in the formula box

 

Fowmy
Super User
Super User

@jimmerph 

Can you share the screenshot of the error message?
It is not clear what exactly you are trying to do and the issue you are facing.


________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

bad copy paste job on my part

 

Total Files = If(sql view name[column name] = "Joe Bloggs",1,0)

 

if i wanted to find the files of jane doe depending on how i add this depends on the error, i have tried many different ways even using switch and cant seem to get the total files or jane doe to show along with joe bloggs.

 

the table i am trying to display as

 

Name of Person           Number of files

joe bloggs                            145
jane doe                               140

Hi @jimmerph 

Create a measure(Modeling menu-.New measure),

 

measure=calculate(DISTINCTCOUNT(table[file id]),allexcept(table, table[Name of person]))

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@jimmerph - you haven't clarified what you are trying to do. This is the Power Query forum, and to do an if/then/else in Power Query, you use the following syntax:

 if [column name] = "Joe Bloggs" then 1 else 0

the if/then/else must be lower case.

If you are in DAX, then it depends. If you are doing a measure, your formula will not work. This might:

 If(MAX('sql view name'[column name]) = "Joe Bloggs",1,0)

I say "might" because it depends on the filter context of the visual.

If it is in a calculated column, then you use this:

 If([column name] = "Joe Bloggs",1,0)

You don't need the table in a calculated column as you cannot reference other tables without using the RELATED() function, and you aren't doing that.

If that isn't what you need, please tell us exactly  how you are trying to do this.

 

How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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.

Top Solution Authors
Top Kudoed Authors