March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
I am stuck with a problem for some time now, and hope to get some help here.
My data contains these for example:
"Count" is the number of available positions in our case, "level" the percentage of how much of this position is allready financed. Every Country can have different amounts of positions with different levels in different years.
What I finally want to show is drawn in this dummy (red numbers are calculated by hand an inserted in the screenshot ;-).
The totals should show the level on either country or total perspective, taking in count the part the level has on a row base compared to the sum of count for the total country (or overall on the bottom).
I manage to get the part for every type (full, part, none), as shown above as "Part of Country". But I have no idea how to calculate the percentage on a higher level, which is the sum of them. Even more complicated (for me): Getting the value for the overall perspective ("Gesamt", german).
What can I do to get results like in the dummy? The pbix for this demo can be found here.
Solved! Go to Solution.
Hi @OliTFD check out my blog post on this (I had a similar case where I wanted to sum quantities per productid , I am pretty sure you will find it useful). It is based on the SUM() OVER PARTITION BY of SQL , I think you can also use the same logic for your COUNT https://www.iipowerblog.com/post/sum-over-partition-by-in-powerbi
@IIPowerBlog At last your idea gave me the solution! I need to drop the measures, and do the calculations in columns, to finally sum them.
First step: Get the count for the country
Total Count per Country COL = CALCULATE(SUM(Facts[Count]),ALLEXCEPT(Facts,Facts[Group],Facts[Country]))
Second: Calculate the count compared to Country
@IIPowerBlog thanks, but this does not seem to work. The Calculate(Sum(... needs a column... but I need to sum values of a measure, which depends on another measure.
As far as I see your solution does more or less the same as my "Total Count per Country)-measure from step 1.
Or do I get things wrong?
Hi @OliTFD check out my blog post on this (I had a similar case where I wanted to sum quantities per productid , I am pretty sure you will find it useful). It is based on the SUM() OVER PARTITION BY of SQL , I think you can also use the same logic for your COUNT https://www.iipowerblog.com/post/sum-over-partition-by-in-powerbi
@amitchandak , AverageX is not the solution, the calculation is a little bit more complex, see below
@v-rzhou-msft Thanks, this part is not the main problem, but thanks for the advise. To get the problem clearer, I try to explain the calculation with the image below:
It is a kind of three-steps-calculation:
- compare the count to the total for country
- multiply this with the level
- sum up this results for the country
The red part is where I am lost ;-). This needs to be the _HAND_CALCULATE-Part.
For the overall total ("Gesamt") it will be more or less the same, just changing step 1 to "compare to total for group".
Hi @OliTFD ,
According to your statement, I think your want to get subtoatl in country level by another calculate logic. However, I am still confused about your calculate logic for red part in your screenshot. Here I suggest you to try ISINSCOPE() function to achieve your goal. Here I use 1 in hand calculate part.
Level % =
VAR _HAND_CALCULATE = 1
RETURN
IF (
ISINSCOPE ( Facts[Type] ),
SUM ( Facts[Level] ),
IF ( ISINSCOPE ( Facts[Country] ), _HAND_CALCULATE )
)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@OliTFD , for the red one, try a measure like
AverageX(Table, [Count]*[Level])
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
User | Count |
---|---|
27 | |
17 | |
16 | |
12 | |
11 |
User | Count |
---|---|
37 | |
29 | |
26 | |
20 | |
16 |