Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi
Below is the Table structure I've got, where I have Store_ID, Transaction_date, Upgrade_date (store upgraded), Sales.
| Store_ID | Transaction_Date | Upgrade_date | Sales |
| 11AB | 01-01-2021 | 24-04-2021 | 100 |
| 11AB | 12-01-2021 | 24-04-2021 | 80 |
| 11AB | 22-02-2021 | 24-04-2021 | 120 |
| 11AB | 13-03-2021 | 24-04-2021 | 200 |
| 11AB | 14-04-2021 | 24-04-2021 | 250 |
| 11AB | 24-04-2021 | 24-04-2021 | 110 |
| 11AB | 05-05-2021 | 24-04-2021 | 290 |
| 11AB | 06-05-2021 | 24-04-2021 | 70 |
| 11AB | 07-05-2021 | 24-04-2021 | 130 |
| 11AB | 08-06-2021 | 24-04-2021 | 50 |
| 24AC | 01-05-2022 | 06-09-2022 | 140 |
| 24AC | 12-06-2022 | 06-09-2022 | 180 |
| 24AC | 22-06-2022 | 06-09-2022 | 160 |
| 24AC | 15-07-2022 | 06-09-2022 | 0 |
| 24AC | 13-08-2022 | 06-09-2022 | 250 |
| 24AC | 14-08-2022 | 06-09-2022 | 250 |
| 24AC | 24-08-2022 | 06-09-2022 | 170 |
| 24AC | 05-09-2022 | 06-09-2022 | 190 |
| 24AC | 06-09-2022 | 06-09-2022 | 170 |
| 24AC | 07-09-2022 | 06-09-2022 | 330 |
| 24AC | 08-10-2022 | 06-09-2022 | 60 |
Below is the result that I'm trying to get, My last 3 Months should be based on Upgade date, If I have an upgrdae date in April, I should consider my last 3 months from 1st Jan till 31st March (April excluded) and My next 3 months should be from 1st April until 30th June. My last and next 3 months average should be as shown in the below table, and my next 3 months (future months) should be based on number of months present in future, If I have data only till October and my upgrade_date is September, I should consider average sales for those 2 months i.e (Sep Sales + Oct Sales)/2. Finally Totals also should be average instead of sum for L3M Avg and N3M Avg
| Store_ID | Upgrade_date | Sales | Last_3_months_(L3M) | Next_3_Months_(N3M) | L3M_Avg | N3M_Avg | |
| 11AB | 24-04-2021 | 1400 | 500 | 900 | 167 | 300 | |
| 24AC | 06-09-2022 | 1900 | 1150 | 750 | 383 | 375 | |
| Total | 3300 | 1650 | 1650 | 275 | 338 |
any help is appreciated, Thanks
Solved! Go to Solution.
Hi, @rookie_963 ;
You could create another measure.
n3m_ave = AVERAGEX(SUMMARIZE('Table',[Store_ID],[Upgrade_date],"1",[N3M_Avg]),[1])
The final show:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @rookie_963 ;
You could create another measure.
n3m_ave = AVERAGEX(SUMMARIZE('Table',[Store_ID],[Upgrade_date],"1",[N3M_Avg]),[1])
The final show:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @rookie_963 ;
Try this measures:
Last_3_months =
CALCULATE(SUM('Table'[Sales]),FILTER(ALL('Table'),
[Store_ID]=MAX('Table'[Store_ID])
&&[Transaction_Date]<=EOMONTH(MAX('Table'[Upgrade_date]),-1)
&&[Transaction_Date]>EOMONTH(MAX('Table'[Upgrade_date]),-4)))Next_3_Months =
CALCULATE(SUM('Table'[Sales]),
FILTER(ALL('Table'),[Store_ID]=MAX('Table'[Store_ID])
&&[Transaction_Date]>EOMONTH(MAX('Table'[Upgrade_date]),-1)
&&[Transaction_Date]<=EOMONTH(MAX('Table'[Upgrade_date]),2)))
L3M_Avg =
var _count=
COUNTROWS(
SUMMARIZE(FILTER('Table',[Store_ID]=MAX('Table'[Store_ID])
&&[Transaction_Date]<=EOMONTH(MAX('Table'[Upgrade_date]),-1)
&&[Transaction_Date]>EOMONTH(MAX('Table'[Upgrade_date]),-4)),[Transaction_Date].[Year],[Transaction_Date].[Month]))
return [Last_3_months]/_countN3M_Avg =
var _count=
COUNTROWS(
SUMMARIZE(FILTER('Table',[Store_ID]=MAX('Table'[Store_ID])
&&[Transaction_Date]>EOMONTH(MAX('Table'[Upgrade_date]),-1)
&&[Transaction_Date]<=EOMONTH(MAX('Table'[Upgrade_date]),2)),
[Transaction_Date].[Year],[Transaction_Date].[Month]))
return [Next_3_Months]/_count
The final show:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-yalanwu-msft
I really appreciate your help, for the above problem I want average to be computed in Totals
I currenlty see that totals are based on max date, if I'm not wrong.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 69 | |
| 63 | |
| 32 | |
| 31 | |
| 23 |