Have an easy one here but can't figure it out
Month
Numerator
Denominator
Jan
4
10
Jan
2
9
Feb
8
1
Feb
4
15
etc.
So the chart has month along the X-axis and then I would want the weight average for each column.
So Jan the average would be 6/19=32%, Feb would be 12/16=75%, etc. etc. --looking for a measure to capture the y-axis data
Create a Calulated Table from the your 'Table':
Calulated Table =
SUMMARIZE(
'Table',
'Table'[Month],
"Weight Average",
DIVIDE(
SUM('Table'[Numerator]),
SUM('Table'[Denominator])
)
)
The result will look like this:
Related
I have a matrix in PowerBI that should be a rolling 12 month view of sales, and I need it to be cumulative. This is what I have so far:
Matrix
The Cumulative Sum row has values of 10 for Oct 2022 and Feb 2023, so I would like it to show 0s until Oct 2022, 10s until Feb 2023, and 20s thereafter.
The values look like this in the dataset:
Dataset
EDIT: The dataset is filtered in the image, there will be multiple rows and values for each month in the unfiltered dataset.
In my data model I have 12 months worth of employee data and month name is in the first column, I.e Jan, Feb Mar etc
I have been using the formula below but I have an issue,
Employee 101 has worked as a sole employee in one department
2 months out of the 12, my formula below will divide that 2/12 equaling =0.16. I want to return average headcount for the department as 1.
So only averaging for months greater 0 employees
DIVIDE(
AVERAGEX(
KEEPFILTERS(VALUES('Date Table'[Month])),
CALCULATE(COUNTROWS(Employee List),Employee List[Emp Status] = "Full Time")),,"")
So use roundup():
roundup(DIVIDE( AVERAGEX( KEEPFILTERS(VALUES('Date Table'[Month])), CALCULATE(COUNTROWS(Employee List),Employee List[Emp Status] = "Full Time")),,""),0)
But you might consider wrapping it in an if() so it only rounds up when the result is less than 1.
I was Averagex and Divide at the same time, removing divide fixed the issue.
I've been struggling with this and hope someone is able to help...
I have a table with sales for products over multiple years. There is a measure that gives me the total revenue for each year by customer, ignoring product sold:
totalRevenueMeasure =
CALCULATE (
SUM ( test[Revenue] ),
ALLEXCEPT ( test, test[company], test[year] )
)
Year company Product revenue totalRevenueMeasure rankx (revenue in year)
2018 company a shoes 100 300 1
2018 company a mugs 200 300 1
2018 Company b shoes 250 250 2
2019 company a lamps 300 300 2
2019 Company b shoes 350 450 1
2019 Company b mugs 100 450 1
2019 Company c mugs 100 100 3
2020 company a shoes 150 150 2
2020 Company c lamps 200 200 1
The closest I got to the RANKX measure is below but this doesn't give the correct results. The expected output is in the RANKX column of the table above.
Customer Rank =
RANKX(
ALLSELECTED( test[company],test[year]),
[TotalRevenueMeasure],
,
DESC,
Dense
)
Thanks in advance for pointers, DAX is still eluding me a bit and there might be a better way to go about it.
Following the recommendation from Alexis, success with test data but live skips some rows in rank - year 2019 doesn't have a rank #1 but has 2 rank #2. I guess this must be some kind of data issue...
You're very close. The problem is that you are looking to rank each year separately but you've removed the Year filter context with your ALLSELECTED function.
Take out the second argument in ALLSELECTED so that you only have company (since you don't actually want to rank over all years for each row).
I have 3 measures:
1) total_trx = SUM(mytable[trx])
2) trx_prev_month = CALCULATE([total_trx], DATEADD(calendar[date], -1,MONTH))
3) monthly_var = DIVIDE([total_trx],[trx_prev_month])-1
If I add a waterfall viz, x-axis with month, it gives me the % of monthly variation and a TOTAL bar at the end that sums all the variations.
I need to reproduce that total number in order to show a KPI as in "so far, we've increased ...%", changing when using a date slicer.
Seems like sum(monthly_var) is not allowed.
Any ideas?
Thank you very much.
Edit1: sample with date filter = Last 4 months
Jul 100 0%
Aug 110 10%
Sep 90 -20%
Oct 80 -10%
Total: -20% <- need a dax to calculate this number and show just -20%
Then if I change the filter to, for example LAST 6 MONTHS, I need to calculate it up to May
In order to get the desired result we will use an intermediate table in our query that will summarize the results by months:
use this code and replace calendar[Year Month] with your Year month column :
SUMX(
SUMMARIZECOLUMNS(calendar[Year Month],"Monthly_int_var",[monthly_var]),
[Monthly_int_var]
)
I am looking for the "best practice" when it comes to calculating Monthly Averages in DAX. Ideally, I would like to use some of the DAX built in Time Intelligence Functions.
I have a measure called "Total Units". Total Units = COUNT(Table[UnitId])
Each row in my table represents when a single unit was sold.
When I put my Total Units and Sales Date into a bar chart, I can see how many units were sold every month.
How do I now calculate the monthly average?
Month Total Units (Sold)
Jan 2019 10
Feb 2019 30
I want a measure that will tell me that the Monthly AVG is (10+30)/2 = 20
There are a couple of ways to solve this. Assuming you have a [Month] column on your table, you could simply do:
MonthlyAvg = DIVIDE ( [Total Units] , DISTINCTCOUNT( 'Table'[Month] ) )
In other words, simply dividing the total with the number of months considered.
If you have a more "proper" data model, with a separate calendar dimension, you should do something like:
MonthlyAvg = AVERAGEX( VALUES( 'Calendar'[Month] ) , [Total Units] )
All you need is a simple average measure as below,
Total Avg = AVERAGE(Total Units (Sold))
When you select any period for date, measure will adjust and provide the average for the selection.
Let's say you select for year 2019 and Months are Jan, Feb, March
(Jan + Feb + March)/3
Hope it helps!!