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 calculated the sales after unique permotions with certain discount_name (discounts can be repeatedly used). Here is the DAX for calculating sales within 48 hours after each promotion which summarized the revenue from "orders" table.
Sales 48h =
VAR date_online = MAX(performance[Date])
RETURN
CALCULATE(
SUM(orders[revenue]),
DATESBETWEEN(orders[date], date_online, date_online + 2)
)
Here is the table "performance"
However, when I sum "sales 48 hours" , the total was wrong. Obviously it has taken the max dates of that month/quarter for calculating sums. For example, the total "sales 48h" for 2020-01 should be (982.38+9484.75+5951.44)=16418.57 not 32,303.20. But I tried modifying the DAX, none of them work 😑. Probably a separate measure calculated on a monthly basis is needed?
Any input is appreciated.
Solved! Go to Solution.
have you tried
measure= sumx(value('performance'[date], Sales 48h)
Proud to be a Super User!
have you tried
measure= sumx(value('performance'[date], Sales 48h)
Proud to be a Super User!
@ryan_mayu
Thank you for your response. I followed your logic and corrected my DAX as
SUMX(VALUES(performance[Date]), performance[Sales 48h]))
And it worked like a charm!!!! Thanks!
You are welcome.
Proud to be a Super User!
@evolve_Tricia , Try like
Sales 48h =
VAR date_online = MAX(performance[Date])
RETURN
CALCULATE(
SUM(orders[revenue]),values(orders[date]), values(orders[promotion]),
DATESBETWEEN(orders[date], date_online, date_online + 2)
)
Sales 48h =
VAR date_online = MAX(performance[Date])
RETURN
sumx( orders,orders[date],orders[promotion] ,"_1"
CALCULATE(
SUM(orders[revenue]),
DATESBETWEEN(orders[date], date_online, date_online + 2)
),[_1])
@amitchandak
Thanks for your prompt respons.
I got the same result from your first DAX. The second one didn't work because orders does not contains "promotion" column. But even if I use performance[promotions], the numbers were not the total of sales 48hr either
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 |
---|---|
97 | |
96 | |
81 | |
74 | |
66 |
User | Count |
---|---|
126 | |
106 | |
105 | |
86 | |
72 |