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 people,
I need your help. I have 3 tables and their relationships as the picture below.
I need to sum up the sales value according to different channel:
Channel A: always sum up sales fromlatest 2 days
Channel B: always sum up sales from latest 2 days
Channel C: always sum up sales from latest day
Do you have any ideas on how I should write the DAX codes? Thanks....
Hi @cmc910514
Please try
Top N Sales =
SUMX (
VALUES ( TableA[Channel] ),
VAR N =
IF ( TableA[Channel] = C, 1, 2 )
VAR T =
TOPN ( N, CALCULATETABLE ( TableC ), TableC[SalesDate] )
RETURN
SUMX ( T, TableC[Value] )
)
@cmc910514
Would you please paste some screenshots of your visual along with the DAX that you have used?
Hi @tamerj1 , just realized that I should revise the table C as below. The sales frequency between different channels is different. Really thanks for your help!
@cmc910514
Anyway, please try
Top N Sales =
SUMX (
VALUES ( TableA[Channel] ),
VAR N =
IF ( TableA[Channel] = C, 1, 2 )
VAR T =
TOPN (
N,
CALCULATETABLE ( VALUES ( TableC[Sales Date] ), ALL ( TableC[Sales Date] ) ),
TableC[SalesDate]
)
RETURN
CALCULATE ( SUM ( TableC[Value] ), KEEPFILTERS ( TableC[Sales Date] IN T ) )
)
I'm not what could be missing. Please share the sample file. I'll work on it tomorrow morning as I don't have access now to my PC. Hopefully, you'll find the solution before.
That should make no difference. Would you please help me out and share the results that you have obtained using my measure?
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 |
---|---|
47 | |
22 | |
20 | |
15 | |
13 |
User | Count |
---|---|
49 | |
41 | |
39 | |
19 | |
19 |