Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
MATRIX:
Rows: [Category], [Range of Units Sold]
Columns: [Date]
Values: [# Sold], [Revenue 000's], [% of total]
I am trying to create a matrix that includes sales information for 3 types of products. I created a measure for "# sold", "Revenue 000's", and now I am trying to create a measure for the revenue of products sold (shown in matrix) by month divided by the overall total revenue for that month. Assume there is data outside of the 3 categories shown in the matrix, but all data still contributes to the total revenue for that month.
The DAX I am currently trying to use is found below. To summerize the meaure I would like to create: (Total [Revenue] for each [Range of Units Sold] per [Category] per [Date]) / (Total [Revenue] per [Date]) = [% of Total]
I have imported 4 tables, 1 table for each month shown in the matrix, which I then apended the 4 months of data into one table. When I try to create the "% of Total" measure, it calulates the same number as "Revenue 000's" which results in "100% of total" most of the time. Please help me with my DAX for the [% of Total] measure. I unfortunately am unable to provide a dataset.
VAR _num = CALCULATE(SUM(Table[Revenue]), FILTER(Table, [Date]=[Date]), Filter(Table, [Category]=[Category]), FILTER(Table, [Range of Units Sold]=[Range of Units Sold]))
VAR _denom = CALCULATE(SUM([Revenue]), ALL(Table[Revenue]), FILTER(Table, [Date]=[Date]))
RETURN
CALCULATE(DIVIDE(_num, _denom)), FILTER(Table, [DATE]=[DATE]))
Hi @Anonymous ,
Assuming you have a date table connected to your Table, I think what you need is as below:
% of Total =
DIVIDE (
SUM ( 'Table'[Revenue] ),
CALCULATE (
[RevenueMeasure],
FILTER (
ALL ( DateTable ),
DateTable[MonthName] = MAX ( DateTable[MonthName] )
),
ALLSELECTED ( 'Table'[Category] ),
ALLSELECTED ( 'Table'[Range of Units Sold] )
)
)
Of course it is better to use YearMonth instead of MonthName in your measure.
If this answer solves your problem, please mark it as an accepted solution and gives it a thumbs up so the others would find what they need easier.
Regards,
Loran
Thank you for your response!
This seems much closer to the result I desire, but there is an issue. The DAX is currently making the denominator the sum of the sales per year. I need the sum of sales per category per month/year as the denominator.
Is there a way to SUM the total revenue per category per month/year for the denominator? I have been trying various things with no luck. Let me know if you need me to explain more clearly.
@Anonymous
Try This:
NEW % of Total =
DIVIDE (
SUM ( 'Table'[Revenue] ),
CALCULATE (
SUMX ( VALUES ( 'Table'[Category] ), [RevenueMeasure] ),
FILTER (
ALL ( DateTable ),
DateTable[MonthName] = MAX ( DateTable[MonthName] )
),
ALLSELECTED ( 'Table'[Range of Units Sold] )
)
)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
105 | |
96 | |
75 | |
63 | |
62 |
User | Count |
---|---|
135 | |
105 | |
104 | |
80 | |
65 |