Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello there BI community!
First time poster here with serious imposter syndrome (pun intended).
I got a database with Transactions table in it. I imported the table to Power BI and I also created a Data table with Year, Month, Week and Day columns (among others), but did not make a relation between the two tables.
Here is a simplified example of the table:Sample data
My goal is to show the Price equally distributed into Year, Month, Week or even Day based on Fields parameters.
I have found a solution that is really close to what I want, but this solution divides up the Price not equally (that is, not in a uniform fashion), but as I understand, it takes the days and rolls them up based on the amount of days in the desired periods.
This results in fluctuating Price values, where February will have lower Price because it has fewer days, and longer months have higher Price.
Here is the DAX code for the example I mentioned above, plus the results I am getting.
Price Distribution = SUMX(
VALUES('Date'[Date]),
CALCULATE(
SUMX(
FILTER(
Transactions,
Transactions[PeriodFrom] <= MAX('Date'[Date]) && Transactions[PeriodTo] >= MIN('Date'[Date])
),
DIVIDE(Transactions[Price],
DATEDIFF(Transactions[PeriodFrom], Transactions[PeriodTo], DAY)+1
)
)
)
)
The results using Field parameters on Year, Month and Week level →
Yearly distribution:Year distribution
Monthly distribution:Month distribution
Month distribution for the Year 2022 only:Month distribution 2022
Weekly distribution only in 2022:Week distribution 2022
The desired outputs should look like this (week output is not here, but I hope the logic is clear) →
Yearly distribution:Year distribution desired output
Monthly distribution for Year 2022:Month distribution 2022 desired output
If You need more information or have any questions, please don't hesitate to ask.
Thank you in advance community and have a lovely day!
@tharunkumarRTK
Do you mean that this 13 period division would solve the weekly distribution problem?
I don't yet see how this method would solve the monthly distribution problem.
As I see it now, your proposed solution would require that I create a separate measure for the Year / Month level, and another one for the week level.
In that case I don't know how I could have the Field parameters applied as shown in the example in my OP.
Could you elaborate on your proposal?
@xmarkx
I think for your requirement, you should consider using a different logic other than Months. You can divide a year into 13 periods, then each period will have 28 days. This way you will be able to distribute your prices equally.
If the post helps please give a thumbs up
If it solves your issue, please accept it as the solution to help the other members find it more quickly.
Tharun
User | Count |
---|---|
84 | |
79 | |
70 | |
47 | |
41 |
User | Count |
---|---|
108 | |
52 | |
50 | |
40 | |
40 |