Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hi
How can I sum the Sales value by ID field and by latest Date of each ID?
The expected result of new measure is: 4567 (B) + 358 (A) + 453 (A) = 5378
Thank you
Sales | Deliverdate | ID |
233 | 18.01.2023 | A |
563 | 18.01.2023 | A |
453 | 01.02.2023 | A |
358 | 01.02.2023 | A |
435 | 01.04.2023 | B |
768 | 04.01.2024 | B |
547 | 11.01.2024 | B |
346 | 11.02.2024 | B |
4567 | 11.04.2024 | B |
Solved! Go to Solution.
Hi, @Dn_wemn
You can try the DAX expression below, I start by creating a measure to calculate the most recent date:
LatestDatePerID =
CALCULATE(
MAX('Table 1'[Deliverdate]),
ALLEXCEPT('Table 1', 'Table 1'[ID])
)
Then create a new measure to calculate the sum:
SumSalesByLatestDateAndID =
SUMX(
FILTER(
'Table 1',
'Table 1'[Deliverdate] = 'Table 1'[LatestDatePerID]
),
'Table 1'[Sales])
Here is my preview:
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data)
Best Regards
Yongkang Hua
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Dn_wemn
You can try the DAX expression below, I start by creating a measure to calculate the most recent date:
LatestDatePerID =
CALCULATE(
MAX('Table 1'[Deliverdate]),
ALLEXCEPT('Table 1', 'Table 1'[ID])
)
Then create a new measure to calculate the sum:
SumSalesByLatestDateAndID =
SUMX(
FILTER(
'Table 1',
'Table 1'[Deliverdate] = 'Table 1'[LatestDatePerID]
),
'Table 1'[Sales])
Here is my preview:
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data)
Best Regards
Yongkang Hua
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you, this has worked.
I tried to do this in one measure, so your first measure was VAR and then I used RETURN to enter your second measure. But this has not worked. Why does it only work in 2 measures? Thx.
Hi,
The latest date of ID A is 01/02/2023. Why are you including 233 in the answer? Shouldn't the answer be 4567+358+453?
Hi, you're right, I corrected this. Thanks
Thanks for your suggestion, this looks good as well.
You are welcome.
Share data in a format that can be pasted in an MS Excel file.
Sales | Deliverdate | ID |
233 | 18.01.2023 | A |
563 | 18.01.2023 | A |
453 | 01.02.2023 | A |
358 | 01.02.2023 | A |
435 | 01.04.2023 | B |
768 | 04.01.2024 | B |
547 | 11.01.2024 | B |
346 | 11.02.2024 | B |
4567 | 11.04.2024 | B |
I dont know how to upload the pbix file though...
Hey @Dn_wemn ,
if you put it in the table, the measure should look like this:
Sales of MaxDate =
VAR _MaxDeliveryDate = CALCULATE ( MAX ( myTable[Deliverdate] ), ALLEXCEPT ( myTable, myTable[ID] ) )
VAR _Sales = CALCULATE ( SUM ( myTable[Sales] ), myTable[Deliverdate] = _MaxDeliveryDate )
RETURN
_Sales
If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
Best regards
Denis
Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic
Hi, thanks, your solution takes the correct max dates and ID, but the total is wrong.
I tried with SUMX but it has not worked either.
Do you know how to get the correct total which is 5378?
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
93 | |
86 | |
80 | |
69 | |
68 |
User | Count |
---|---|
226 | |
129 | |
119 | |
83 | |
77 |