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

Working with variable

Hello,

 

I am trying to use variable function for the first time and it does not recognize the table and/or the field.  Does it work, even if the table are not linked.

 

Here's a copy of the pbix

Regards

 

 

https://1drv.ms/u/s!At4hIgQFrUxYjVIYRSj6hBaaqoDV?e=NlbuEO

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Does that make sense? If so, please mark the helpful answer as the solution. More people will benefit from here. If you still have questions, please feel free to ask us.

 

Best Regards,
Xue Ding
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

6 REPLIES 6
Pragati11
Super User
Super User

Hi @Anonymous ,

 

In your pbix file, I can see that you are creating a dax calculation: 

 

You measure as follows:

Distribution =
VAR
Distribution=Switch(true(),
'Project info'[NBL] && 'Project info'[BudgetRevenu],"Flat","none")
RETURN distribution
 
A measure requires a summarisation on table columns like SUM, MIN, MAX.
 

The other thing is in the above measure in one table, you are using column from someother table.

You can only do this when these 2 tables are related to eachother.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

@Anonymous, first of all, you are adding a measure and in a measure, you have to use some sort of aggregation to use the column name which you are not doing in your measure.

 

Now to your original question, what you are trying to achieve? You need to provide a bit more context about your question and what you are trying to achieve. Not necessarily VARiables are always required, it depends on what you are trying to achieve. Putting a question without context is very hard to answer.

 

Read this post to get your answer quickly.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

amitchandak
Super User
Super User

@Anonymous , what is variable function ?

Anonymous
Not applicable

I mean using a measure such as:

 

Distribution =
VAR
Distribution=Switch(true(),
'Project info'[NBL] && 'Project info'[BudgetRevenu],"Flat","none")
RETURN distribution

Hi @Anonymous ,

 

Not clear about what you want. You could try this firstly:

Distribution =
VAR Distribution =
    SWITCH (
        TRUE (),
        MAX ( 'Project info'[NBL] ) <> BLANK ()
            && SUM ( 'Project info'[BudgetRevenue] ) <> BLANK (), "Flat",
        "none"
    )
RETURN
    Distribution

1.PNG

There are a few points about your formula:

  • As the users above said, measures need to specify an aggreation such as min,max,sum or count etc.. It is not supported to use columns directly.

Distribution =
VAR
Distribution=Switch(true(),
'Project info'[NBL] && 'Project info'[BudgetRevenu],"Flat","none")
RETURN distribution

 

  • They are not boolean type for your columns "NBL" and "BudgetRevenu". So you need to add conditions to get constant values to match the expression.

Distribution =
VAR
Distribution=Switch(true(),
'Project info'[NBL] && 'Project info'[BudgetRevenu],"Flat","none")

RETURN distribution

 

  • The name of variables need to be same as ones while defining.

Distribution =
VAR
Distribution=Switch(true(),
'Project info'[NBL] && 'Project info'[BudgetRevenu],"Flat","none")

RETURN distribution

 

You could tabke a look at the documents to learn more.

Create measures for data analysis in Power BI Desktop 

SWITCH 

VAR 

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Anonymous ,

 

Does that make sense? If so, please mark the helpful answer as the solution. More people will benefit from here. If you still have questions, please feel free to ask us.

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.