Cumulative count DAX (PBI) - dax

I have a list of goods and I want to create a column calculating the % of goods as I move along the column with DAX

Related

Is there a method for calculating a stacked subtracted and summed tier in Power Pivot (DAX)

Column W gives a simple explanation on how it should be calculated for quantity 500.. For a normal stack tier I have a working DAX formula below. However, that does not work for a stacked subtracted and summed tier.
VAR _quantity = [Quantity]
VAR _year_product = Quantity2022[YearProduct]
RETURN
MINX(FILTER(PriceList;
AND(_year_product=PriceList[YearProduct];_quantity>=PriceList[QFrom]));
PriceList[Price]*[Quantity]))
How can I do the same for a stacked tier?

Percentile Category group in DAX

I have created 3 percentiles namely 30, 50 & 65th Percentile for frame size. And these values I need to compare with values in another table to get the attractiveness with the below logic. Can anyone help to get it in dax code.
Attractiveness If 65th percentile > Gold --> Attractiveness = High
ELSE,
If 30th Percentile > Bronze --> Attractiveness = Average
ELSE, --> Attractiveness = Low
Tables

filter cost center with GL account and take the total

I am trying to filter the column "E" with each cost center, column "L" with each GL account and get the sum of amount column "I" in new sheet with entire row values. Also the negative amount to be highlighted. There are 75000 rows with 200 cost centers.

Algorithm : calculate total price using decomposition recursion

I'm designing an algorithm that calculate the total price of a product.
The product can be composed by composite ingredient (X,Y,Z) or basic ingredient (a,b,c), the basic ingredient each is associated with a price.
The composite ingredient is itself composed by other composite or ingredient. E.g.: X (composite) = Z (composite) + a (basic ingredient)
Now to calculate the total price of a product, I now use a recursion algorithm that decompose each composite ingredient into basic ingredient, and sum up their price.
I want to know if there is better algorithm already to solve this kind of problems ?
Thanks.

How do I create a population sample that follows specified demographics?

I have the following class:
class Person
{
GenderEnum Gender;
RaceEnum Race;
double Salary;
...
}
I want to create 1000 instances of this class such that the collection of 1000 Persons follow these 5 demographic statistics:
50% male; 50% female
55% white; 20% black; 15% Hispanic; 5% Asian; 2% Native American; 3% Other;
10% < $10K; 15% $10K-$25K; 35% $25K-$50K; 20% $50K-$100K; 15% $100K-$200K; 5% over $200K
Mean salary for females is 77% of mean salary for males
Mean Salary as a percentage of mean white salary:
white - 100%.
black - 75%.
Hispanic - 83%.
Asian - 115%.
Native American - 94%.
Other - 100%.
The categories above are exactly what I want but the percentages given are just examples. The actual percentages will be inputs to my application and will be based on what district my application is looking at.
How can I accomplish this?
What I've tried:
I can pretty easily create 1000 instances of my Person class and assign the Gender and race to match my demographics. (For my project I'm assuming male/female ratio is independent of race). I can also randomly create a list of salaries based on the specified percentage brackets. Where I run into trouble is figuring out how to assign those salaries to my Person instances in such a way that the mean salaries across gender and mean salaries across race match the specified conditions.
I think you can solve this by assuming that the distribution of income for all categories is the same shape as the one you gave, but scaled by a factor which makes all the values larger or smaller. That is, the income distribution has the same number of bars and the same mass proportion in each bar, but the bars are shifted towards smaller values or towards larger values, and all bars are shifted by the same factor.
If that's reasonable, then this has an easy solution. Note that the mean value of the income distribution over all people is sum(p[i]*c[i], i, 1, #bars), which I'll call M, where p[i] = mass proportion of bar i and c[i] = center of bar i. For each group j, you have the mean sum(s[j]*p[i]*c[i], i, 1, #bars) = s[j]*M where s[j] is the scale factor for group j. Furthermore you know that the overall mean is equal to the sum of the means of the groups, weighting each by the proportion of people in that category, i.e. M = sum(s[j]*M*q[j], j, 1, #groups) where q[j] is the proportion of people in the group. Finally you are given specific values for the mean of each group relative to the mean for white people, i.e. you know (s[j]*M)/(s[k]*M) = s[j]/s[k] = some fraction, where k is the index for the white group. From this much you can solve these equations for s[k] (the scaling factor for the white group) and then s[j] from that.
I've spelled this out for the racial groups only. You can repeat the process for men versus women, starting with the distribution you found for each racial group and finding an additional scaling factor. I would guess that if you did it the other way, gender first and then race, you would get the same results, but although it seems obvious I wouldn't be sure unless I worked out a proof of it.

Resources