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
Trooz
Helper I
Helper I

VAR measure to get the ratio

Hello All,

 

I'm writing this to seek your assistance to help me understand how this measure can be performed 🙂

 

Please check the the images and adivse how can I get this result. (I didn't find VAR in the DAX suggestions but I found other types of VAR+s/p ect.,)

 

data.pngdata2.png

 

4legratio.png

 

report.png

 

Many thanks 🙂

5 REPLIES 5
Anonymous
Not applicable

"I'm writing this to seek your assistance to help me understand how this measure can be performed"

 

This measure... WHICH MEASURE? I'm trying to guess from the pictures... The only sensible guess would be you want a measure that will show the ratio of all currently visible purchases to 4-legged animals. If this IS the case, then:

[Total Quantity] = SUM( Purchase[Quantity] )

[FourLeggedRatio] =
var __4leggedQty =
	CALCULATE(
		[Total Quantity],
		'Product'[Legs] = 4
	)
var __totalQty = [Total Quantity]
var __ratio =
	DIVIDE(
		__totalQty,
		__4leggedQty
	)
return
	__ratio

 

Is this what you wanted?

 

Best

D

Thank you @Anonymous I appreciate your reply and I'm sorry for not being sufficiently clear.

I just would like to perform the same function shown above in the image in only one step. 

 

4legratio.png

 I'm unable to write all those functions in the same tab, as you see in the right part of the page "All measures" contains only one measure "FourLeggedRatio" and in the left part you can see that they peformed four comands in only one measure. 

vivran22
Community Champion
Community Champion

Hello @Trooz ,

 

Is your objective is to understand how the DAX measure you have posted is working and why you can't find VAR in the DAX intellisense list? Please confirm.

 

You will not get VAR in the DAX intellisense list. The common syntax is:

 

[Measure Name/Calculated Column Name] = 

VAR [VariableName1] = Expression1

 

VAR [VariableName2] = Expression2

RETURN

 

Expression3

 

VAR.P and VAR.S is formula for calculating variance of population and sample respectively.

 

Cheers!
Vivek

If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂

https://www.vivran.in/

Connect on LinkedIn

 

 

 

@vivran22  hi Vivran

thank you for your reply 🙂 , yes I want to apply the same function in power BI, as shown in the images they wrote four commands un the same function/DAX.

You told me that I cannot find "VAR" but in the examole above I don't know how they got it.

 

vivran22
Community Champion
Community Champion

@Trooz 

When I said that you cannot find VAR in PBI, I meant you will not get it in the intellisence suggestions. VAR is a short form of Variable, which stores the result of an expression.

 

You may find following articles helpful:

 

https://docs.microsoft.com/en-us/dax/var-dax

https://blog.enterprisedna.co/using-variables-in-dax-a-detailed-example/

 

Cheers!
Vivek

If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂

https://www.vivran.in/

Connect on LinkedIn

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