Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi Guys,
I need help,
Below are my current result
CustomerName | Status | SalesAmount | PY SalesAmount |
Customer 1 | Growing | 167,088 | 49,588 |
Customer 2 | New | 34,470 | 0.00 |
Customer 3 | New | 5,400 | 0.00 |
Customer 4 | Growing | 11,191 | 436.62 |
Customer 5 | Declining | 1,164 | 27,775 |
1 ) Calculated Sales Amount using measure
Solved! Go to Solution.
"i change to use calculated column"
Why? I thought your goal was to do everything with measures?
Here is the formula for the calculated column version:
Column Group =
SWITCH(TRUE(),
ISBLANK([PY SalesAmount]) && ISBLANK([SalesAmount]),"Inactive",
ISBLANK([PY SalesAmount]) && not ISBLANK([SalesAmount]),"New",
not ISBLANK([PY SalesAmount]) && ISBLANK([SalesAmount]),"Lost",
[SalesAmount]>[PY SalesAmount],"Increasing",
[SalesAmount]<[PY SalesAmount],"Declining",
"Same")
Hi Ibendlin,
It's worked, thankyou so much! Appreciate.
Glad to hear. Just to reiterate - you cannot count measure values. You need to formulate the business requirement and then write another measure that implements the associated logic.
Also note that my first measure is not fully covering all scenarios. (for example when both current and previous year values are blank). Adjust as needed.
Okay, noted. I will check first measure. But i still having problem here, i change to use calculated column for TY sales amount and PY sales amount, but the PY Sales amount show blank. Can you please advise?
Thanks.
"i change to use calculated column"
Why? I thought your goal was to do everything with measures?
Here is the formula for the calculated column version:
Column Group =
SWITCH(TRUE(),
ISBLANK([PY SalesAmount]) && ISBLANK([SalesAmount]),"Inactive",
ISBLANK([PY SalesAmount]) && not ISBLANK([SalesAmount]),"New",
not ISBLANK([PY SalesAmount]) && ISBLANK([SalesAmount]),"Lost",
[SalesAmount]>[PY SalesAmount],"Increasing",
[SalesAmount]<[PY SalesAmount],"Declining",
"Same")
Because yesterday the first measure you advise was referring to table column. That's why i changed to used calculated column.
var t= calculate(sum('Table'[SalesAmount])) var p= CALCULATE(sum('Table'[PY SalesAmount]))
But the latest calculated column version solved my problem.
Many Thanks!!
Hi Ibendlin,
I'm New in Power BI. If use calculated columns meaning all measures change to calculated columns for Sales amount, PY Sales amount and status?
Thanks
Calculated columns are only computed once during dataset refresh. Measures are recomputed each time the user interacts with the report. More flexibiliy, at the expense of more compute.
I had tried to use calculated columns for all the measure, but the result was wrong that's why i use all measure. Can i count the measure?
Not really, you need a separate measure for that. (It is the recommended approach anyway).
Here is the first measure:
Group =
var t= calculate(sum('Table'[SalesAmount]))
var p= CALCULATE(sum('Table'[PY SalesAmount]))
return if(HASONEVALUE('Table'[CustomerName]),switch(TRUE(), ISBLANK(t),"Lost",ISBLANK(p),"New",t>p,"Growing",p>t,"Declining","Same"))
Here is the second measure:
Customers =
var s = SELECTEDVALUE(Groups[Group])
var a = ADDCOLUMNS(VALUES('Table'[CustomerName]),"TY",calculate(sum('Table'[SalesAmount])),"PY",calculate(sum('Table'[PY SalesAmount])))
var b = ADDCOLUMNS(a,"Match",SWITCH(TRUE(),
s="Lost" && not ISBLANK([PY]) && ISBLANK([TY]),1,
s="New" && not ISBLANK([TY]) && ISBLANK([PY]),1,
s="Declining" && not ISBLANK([TY]) && not ISBLANK([PY]) && [TY]<[PY],1,
s="Growing" && not ISBLANK([TY]) && not ISBLANK([PY]) && [TY]>[PY],1,
s="Same" && not ISBLANK([TY]) && not ISBLANK([PY]) && [TY]=[PY],1,
0))
return if(hasonevalue(Groups[Group]),sumx(b,[Match]))
See attached.
Just to confirm - you want this all as measures? (it would be easier as calculated columns).
You are also missing the scenario when the two values match.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
131 | |
80 | |
53 | |
38 | |
35 |
User | Count |
---|---|
207 | |
82 | |
75 | |
55 | |
50 |