Forum Discussion
aggregation at customer name level
desired output
Month Total 2023 Total 2024 LFL 2023 LFL 2024
| Jan | 20 | 35 | 20 | 27 |
| Feb | 21 | 31 | 21 | 22 |
| Mar | 20 | 37 | 20 | 28 |
| Apr | 32 | 33 | 12 | 33 |
Goal:
- Total 2023: Sum the sales for 2023 for each month.
- Total 2024: Sum the sales for 2024 for each month.
- LFL 2023: For each month, calculate the total 2023 sales only for stores that have sales in both 2023 and 2024 for that same month.
- LFL 2024: For each month, calculate the total 2024 sales only for stores that have sales in both 2023 and 2024 for that same month.
data
Month Store 2023 Sales 2024 Sales
| Jan | S23 | 10 | 12 |
| Jan | S24 | 10 | 15 |
| Jan | S25 | (blank) | 8 |
| Feb | S23 | 12 | 11 |
| Feb | S24 | 9 | 11 |
| Feb | S25 | (blank) | 9 |
| Mar | S23 | (blank) | 9 |
| Mar | S24 | 15 | 18 |
| Mar | S25 | 5 | 10 |
| Apr | S23 | 20 | (blank) |
| Apr | S24 | 2 | 21 |
| Apr | S25 | 10 | 12 |
4 Replies
- Kedar_PandeSuper User
Use the following DAX measures:
Total 2023 = SUM('Table'[2023 Sales])Total 2024 = SUM('Table'[2024 Sales])LFL 2023 =
CALCULATE(
SUM('Table'[2023 Sales]),
FILTER(
'Table',
NOT(ISBLANK('Table'[2023 Sales])) &&
NOT(ISBLANK('Table'[2024 Sales]))
)
)LFL 2024 =
CALCULATE(
SUM('Table'[2024 Sales]),
FILTER(
'Table',
NOT(ISBLANK('Table'[2023 Sales])) &&
NOT(ISBLANK('Table'[2024 Sales]))
)
)Create a table visual with Month as rows and the four measures as columns.
- Hemant_JaiswarHelper I
no
- LFL 2023: For each month, calculate the total 2023 sales only for stores that have sales in both 2023 and 2024 for that same month.
- LFL 2024: For each month, calculate the total 2024 sales only for stores that have sales in both 2023 and 2024 for that same month.
and in my output there is only month dimensionMonth Total 2023 Total 2024 LFL 2023 LFL 2024
Jan 20 35 20 27 Feb 21 31 21 22 Mar 20 37 20 28 Apr 32 33 12 33
- AnonymousNot applicable
Hi Hemant_Jaiswar ,
I want to acknowledge valuable input provided by Kedar_Pande . Their initial ideas help guide my approach. However, I noticed that more details are needed to fully understand this issue.
(1) Create a column.
Flag = IF([2023 Sales]<>BLANK() && [2024 Sales]<> BLANK(),1,0)(2) Then create a new table.
Table 2 = ADDCOLUMNS ( VALUES ( 'Table'[Month] ), "Total 2023", CALCULATE ( SUM ( 'Table'[2023 Sales] ), FILTER ( 'Table', 'Table'[Month] = EARLIER ( 'Table'[Month] ) ) ), "Total 2024", CALCULATE ( SUM ( 'Table'[2024 Sales] ), FILTER ( 'Table', 'Table'[Month] = EARLIER ( 'Table'[Month] ) ) ), "LFL 2023", CALCULATE ( SUM ( 'Table'[2023 Sales] ), FILTER ( 'Table', [Flag] = 1 && 'Table'[Month] = EARLIER ( 'Table'[Month] ) ) ), "LFL 2024", CALCULATE ( SUM ( 'Table'[2024 Sales] ), FILTER ( 'Table', [Flag] = 1 && 'Table'[Month] = EARLIER ( 'Table'[Month] ) ) ) )Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Ashish_MathurSuper User
Why have you posted this question multiple times. See my response here - context change - Microsoft Fabric Community