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
Anonymous
Not applicable

Scripting

How do we create scripts in power bi?

 

For example, if I want to create if statement, do i just create a New column and type the if statement, or is there a seperate scripting space?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Right click your Ediables column in Field Pane, select New Group, and there you can Select Strawbery and Mango and Name it as Fruits. You can create other group as well.

 

Thanks
Raj

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

Hi @Anonymous

 

Power BI uses DAX language for this purpose. You need to create Either Calculated column, Measure or DAX table to use the DAX code.

 

You can right click your table name in the Field pane and create new column/ Measure to use DAX.

 

Alternatively, go to Modelling tab and create them.

 

DAX Usage.PNG

Thanks

Raj

Anonymous
Not applicable

thank you!

 

However, I am not able to access a variable from the particular table while creating a measure. Suppose I have the table animal and I need to access a variable under it for my if statemet, then creating a measure does not help me do this. 

 

Is there a solution for this?

@AnonymousYou create variables in Column and measure my using syntax Var map so map is the varaible name

 

Var.PNG

Anonymous
Not applicable

Is that a new variable?

 

This is my situation. Suppose I have loaded an Excel file called 'Things'. Under Things, I have a column called 'Edibles'. So I need to create a new group called 'Fruits.' 

 

Something like.. if (edibles = apple or edible = mango) as fruits.

 

This is what I want to perform.

@Anonymous Can you provide sample data?

Anonymous
Not applicable

Ya, my table looks something like this. The excel file is called as things.

 

Edibles           Living      Non-Living

 

Chocolate         A               B

Strwaberry        X                Y

Mango             Humans     Pen

 

So i want a group: if edibles = strawberry or mango, then it should be under a new group called fruits

Anonymous
Not applicable

Right click your Ediables column in Field Pane, select New Group, and there you can Select Strawbery and Mango and Name it as Fruits. You can create other group as well.

 

Thanks
Raj

Anonymous
Not applicable

Thank you!

Anonymous
Not applicable

I think you refer measure as variable here.

 

Create a calculated column and try.

 

Please share sample data in editable format, if you need further help on this.

 

Thanks

Raj

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.