Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
I have been wrestling to understand how logically the following to statements or (measures) are providing different results.
Sales PCT_1 =
var current_sales = sumx(sales, Sales[Quantity]*Sales[Net Price])
var all_sales = calculate(current_sales,all('Product Category'[Category]))
var pct_ratio = DIVIDE(current_sales,all_sales,0)
return pct_ratio
Sales PCT_2 =
var current_sales = sumx(sales, Sales[Quantity]*Sales[Net Price])
var all_sales = calculate(sumx(sales, Sales[Quantity]*Sales[Net Price]),all('Product Category'[Category]))
var pct_ratio = DIVIDE(current_sales,all_sales,0)
return pct_ratio
(the first one provides all results 100% and ingnores all filters even while the later one provides better results when I categorise the result)
I would be gratefull if someone help me how using the statement or the variable have made the changes.
Thanks in advance.
Solved! Go to Solution.
Variables are not variable, they are constant.
You cannot alter the value of a variable once it has been assigned. Therefore this line of code does not change the value of the variable
var all_sales = calculate(current_sales,all('Product Category'[Category]))
Variables are not variable, they are constant.
You cannot alter the value of a variable once it has been assigned. Therefore this line of code does not change the value of the variable
var all_sales = calculate(current_sales,all('Product Category'[Category]))
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
21 | |
15 | |
11 | |
10 | |
10 |