Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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]))
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
18 | |
7 | |
7 | |
5 | |
5 |
User | Count |
---|---|
23 | |
10 | |
10 | |
9 | |
7 |