Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi,
I am learning X-Functions in PowerBI. I have table (visitData) in which there are 4 customer and their total number of visit and their spent per visit.
Customer, SpendPerVisit,No.OfVisit a,50,7 b,40,3 c,100,12 d,15,4
Now, i am using measure to calculate their total spent per visit and AverageSpentPerVisit without using X-functions
AverageSpentPerVisit Wrong = AVERAGE(VisitData[spend per visit]) TotalSpentPerVisit = [AverageSpentPerVisit Wrong] * [TotalNoOfVisit]
AverageSpentPerVisit New = DIVIDE([TotalSpentSumX],[TotalNo.OfVisit New])
Solved! Go to Solution.
Hi @affan,
Thanks for reply and helpin me. your solution is also working.
But i got work around the solution and i check the matrix total is right. Why, because
in this case, in the Total column is like :-
TotalOfTotalSpendPerVisit/TotalOfTotalNo.OfVisit
That's Why it is showing me $51 in first matrix and $66 in second matrix.
If you see both of your total results you can understand that both of them are wrong.
In AverageSpentPerVisit Wrong the total is shown as 51.25.
In AverageSpentPerVisit New the total is shown as 66.54
Whereas the total should be 205. Your issue is not with the SUM or SUMX it is regarding the 'Row Context'
AverageSpentPerVisit Wrong = var _avg=AVERAGE(VisitData[spend per visit]) return IF(HASONEVALUE(VisitData[Customer]),_avg,SUMX(VALUES(VisitData[Customer]),_avg))
If this helped you, please mark this post as an accepted solution and like to give KUDOS .
Regards,
Affan
Hi @affan,
Thanks for reply and helpin me. your solution is also working.
But i got work around the solution and i check the matrix total is right. Why, because
in this case, in the Total column is like :-
TotalOfTotalSpendPerVisit/TotalOfTotalNo.OfVisit
That's Why it is showing me $51 in first matrix and $66 in second matrix.
Glad to hear that. You may help accept the solution above. Your contribution is highly appreciated.
You can check the following links. They are describing your issue:
https://exceleratorbi.com.au/use-sum-vs-sumx/
https://powerpivotpro.com/2014/10/sum-sumx-or-calculatechoices-choices/
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 45 | |
| 44 | |
| 20 | |
| 19 |
| User | Count |
|---|---|
| 73 | |
| 71 | |
| 34 | |
| 33 | |
| 31 |