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.
Hi,
I have a situation where I need to show what is the discount on which maximum sales happened for a geography key.
For e.g
There could be two geographies A and B having 2 sub areas 1 and 2. So there will be 4 geographic keys. A1,A2,B1,B2.
For each key there will be multiple invoices at various discounts,
My problem is to show in a single tabular report, what is total sales for each geography and what is the discount at which highest sales is happening.
For eg.
Suppose for A1 I have as below:
Geography Sub region Discount Sales
A 1 30% $100
A 1 40% $80
The output report should be like
Geography Subregion Total Sales Discount at which highest sales is
A 1 $180 30%
Can you pls guide.
Solved! Go to Solution.
Hi @Prasad84
Use the below formula to create a new column for total sales:
Total_Sales = CALCULATE(SUM(Sales[Sales]),FILTER(Sales,Sales[Geography]=EARLIER(Sales[Geography]) && Sales[Subregion]=EARLIER(Sales[Subregion])))
To get the discount , corresponding to the max sales, create a flag column to mark the row which has max sales for each geo/ subregion
Max_sales = IF( CALCULATE(MAX(Sales[Sales]),FILTER(Sales,Sales[Geography]=EARLIER(Sales[Geography])&& Sales[Subregion]=EARLIER(Sales[Subregion])))=Sales[Sales],1,0)
and then display the discount where the flag is 1.
max_discount = SWITCH(TRUE(),Sales[Max_sales]=1,Sales[Discount])
To display only the records where max sales happens, filter using Max_sales=1
Hope this helps.
P.S: To get the second table, pls select do not summarize option of the newly created columns. ( Go to visualizations-> Fields tab -> Values section-> right click the colun-> select do not summarize)
Thanks
Raj
You may also use measure below.
Measure = MAXX ( TOPN ( 1, Table1, Table1[Sales], DESC ), Table1[Discount] )
Hi @Prasad84
Use the below formula to create a new column for total sales:
Total_Sales = CALCULATE(SUM(Sales[Sales]),FILTER(Sales,Sales[Geography]=EARLIER(Sales[Geography]) && Sales[Subregion]=EARLIER(Sales[Subregion])))
To get the discount , corresponding to the max sales, create a flag column to mark the row which has max sales for each geo/ subregion
Max_sales = IF( CALCULATE(MAX(Sales[Sales]),FILTER(Sales,Sales[Geography]=EARLIER(Sales[Geography])&& Sales[Subregion]=EARLIER(Sales[Subregion])))=Sales[Sales],1,0)
and then display the discount where the flag is 1.
max_discount = SWITCH(TRUE(),Sales[Max_sales]=1,Sales[Discount])
To display only the records where max sales happens, filter using Max_sales=1
Hope this helps.
P.S: To get the second table, pls select do not summarize option of the newly created columns. ( Go to visualizations-> Fields tab -> Values section-> right click the colun-> select do not summarize)
Thanks
Raj
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 |
---|---|
110 | |
95 | |
76 | |
65 | |
51 |
User | Count |
---|---|
146 | |
109 | |
106 | |
88 | |
61 |