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 everyone,
I have a problem, where I can't get the calculation of the Row "RABAT" (Discount)" calculated to a percentage of SalesAmount, and then afterwards to be subtracted from SalesAmount.
In this specific case, I want the:
63,35 / 1.267 = 5% = Discount ("RABAT")
294 * (1-5%) = 279,3
237 * (1-5%) = 225,15
191,2 * (1-5%) = 181,64
162 * (1-5%) = 153,9
156 * (1-5%) = 148,2
149,4 * (1-5%) = 141,93
77,4 * (1-5%) = 73,53
Total SalesAmount = 1.203,65
I have tried with this measure:
Meanwhile please also try
SalesAmount =
SUMX (
SUMMARIZE ( 'Værdiposter', 'Værdiposter'[Bilagsnr.], 'Værdiposter'[Varenr.] ),
CALCULATE (
VAR CurrentVarenr =
SELECTEDVALUE ( 'Værdiposter'[Varenr.] )
VAR CurrentAmont =
IF (
CurrentVarenr IN { "RABAT", "FRAGT", "KAMPAGNE" },
0,
SUM ( 'Værdiposter'[Salgsbeløb (faktisk)] )
)
VAR DiscountAmount =
CALCULATE (
SUM ( 'Værdiposter'[Salgsbeløb (faktisk)] ),
'Værdiposter'[Varenr.] = "RABAT",
ALLEXCEPT ( 'Værdiposter', 'Værdiposter'[Bilagsnr.] )
)
VAR TotalAmount =
CALCULATE (
SUM ( 'Værdiposter'[Salgsbeløb (faktisk)] ),
FILTER (
'Værdiposter',
NOT ( 'Værdiposter'[Varenr.] IN { "RABAT", "FRAGT", "KAMPAGNE" } )
),
VALUES ( 'Værdiposter'[Bilagsnr.] ),
REMOVEFILTERS ()
)
VAR DiscountPercentage =
DIVIDE ( DiscountAmount, TotalAmount )
RETURN
CurrentAmont * ( 1 + DiscountPercentage )
)
)
@tamerj1 maybe you want to give it another shot? Because the last formula weren't giving the correct output.
Yes, gives the same result as the other one.
@Jonas_Holm
Please try
SalesAmount =
SUMX (
SUMMARIZE ( 'Værdiposter', 'Værdiposter'[Bilagsnr.], 'Værdiposter'[Varenr.] ),
CALCULATE (
VAR CurrentVarenr =
SELECTEDVALUE ( 'Værdiposter'[Varenr.] )
VAR CurrentAmont =
IF (
CurrentVarenr IN { "RABAT", "FRAGT", "KAMPAGNE" },
0,
SUM ( 'Værdiposter'[Salgsbeløb (faktisk)] )
)
VAR DiscountAmount =
CALCULATE (
SUM ( 'Værdiposter'[Salgsbeløb (faktisk)] ),
'Værdiposter'[Varenr.] = "RABAT",
ALLEXCEPT ( 'Værdiposter', 'Værdiposter'[Bilagsnr.] )
)
VAR TotalAmount =
CALCULATE (
SUM ( 'Værdiposter'[Salgsbeløb (faktisk)] ),
FILTER (
'Værdiposter',
NOT ( 'Værdiposter'[Varenr.] IN { "RABAT", "FRAGT", "KAMPAGNE" } )
),
ALLEXCEPT ( 'Værdiposter', 'Værdiposter'[Bilagsnr.] )
)
VAR DiscountPercentage =
DIVIDE ( DiscountAmount, TotalAmount )
RETURN
CurrentAmont * ( 1 + DiscountPercentage )
)
)
Hello @tamerj1
The result is getting closer to the prefered result.
But the discount should only be applied to the "Varenr. RABAT" - which in this case is 5%. But I cannot see, what I should re-do in your formula, to get this to work as intended. Hope you can help me further.
this is the prefered result I want to receive.
Ok I will into it tomorrow morning. Actually I don't have data to work with I only typed the code on my phone. Please help me out by returning the variables and check what values you get. Thank you
this great thank you. It is clear noe thaere a filter comming from another table? Please share a screenshot or your data model. From which tables are the columns involved in this table visual?
this one, because I have tried that.
SalesAmount = SUMX ( SUMMARIZE ( 'Værdiposter', 'Værdiposter'[Bilagsnr.], 'Værdiposter'[Varenr.] ), CALCULATE ( VAR CurrentVarenr = SELECTEDVALUE ( 'Værdiposter'[Varenr.] ) VAR CurrentAmont = IF ( CurrentVarenr IN { "RABAT", "FRAGT", "KAMPAGNE" }, 0, SUM ( 'Værdiposter'[Salgsbeløb (faktisk)] ) ) VAR DiscountAmount = CALCULATE ( SUM ( 'Værdiposter'[Salgsbeløb (faktisk)] ), 'Værdiposter'[Varenr.] = "RABAT", ALLEXCEPT ( 'Værdiposter', 'Værdiposter'[Bilagsnr.] ) ) VAR TotalAmount = CALCULATE ( SUM ( 'Værdiposter'[Salgsbeløb (faktisk)] ), FILTER ( 'Værdiposter', NOT ( 'Værdiposter'[Varenr.] IN { "RABAT", "FRAGT", "KAMPAGNE" } ) ), ALLEXCEPT ( 'Værdiposter', 'Værdiposter'[Bilagsnr.] ) ) VAR DiscountPercentage = DIVIDE ( DiscountAmount, TotalAmount ) RETURN CurrentAmont * ( 1 + DiscountPercentage ) ) )
I had also tried the one with removefilters - same result.
@Jonas_Holm , Now very clear. But if this discount %
CALCULATE(SUM('Værdiposter'[Salgsbeløb (faktisk)]),
FILTER(ALL('Værdiposter'[Varenr.]),'Værdiposter'[Varenr.]="RABAT"))
Then sales value is
(1- CALCULATE(SUM('Værdiposter'[Salgsbeløb (faktisk)]),
FILTER(ALL('Værdiposter'[Varenr.]),'Værdiposter'[Varenr.]="RABAT")) ) * Salesamount
or
sumx( 'Værdiposter' , (1- CALCULATE(SUM('Værdiposter'[Salgsbeløb (faktisk)]),
FILTER(ALL('Værdiposter'[Varenr.]),'Værdiposter'[Varenr.]="RABAT")) ) * Salesamount )
@amitchandak maybe I wasn't totally clear, but the way you made the calculations doesn't seem to work.
I have made this formula from SumX
And sales amount is:
I even tried to make the sumx calculation:
Do you have another idea, on how to calculate the discount % and use that for each row?
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 | |
26 | |
19 | |
14 | |
10 |
User | Count |
---|---|
57 | |
49 | |
44 | |
18 | |
18 |