The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello
I have a transaction table with the following data:
Transaction date | Amount | Urgency | Customer |
1-1-2017 | 50 | high | a |
30-5-2017 | 100 | medium | a |
30-9-2017 | 30 | low | a |
1-1-2018 | 45 | medium | a |
20-2-2018 | 55 | low | a |
I want to summarise the data per year per urgency. Besides that each customer should be allocated to the transaction with the highest urgency within a year.
So finally I need to have:
2017 | 2018 | |
High | 180 | 0 |
Medium | 0 | 100 |
Low | 0 | 0 |
I would appreciate your help!
Regards,
Jarno
Solved! Go to Solution.
If you follow the Star Schema approach which LivioLanzo showed, then you can also use the below Calculated column HighestUrgencyID in Data table, and create a relationship between Urgency[UrgencyID] & Data[HighestUrgencyID]. This way your measure will be just SUM(Data[Amount]).
HighestUrgencyID = VAR TransactionYear = RELATED ( 'Calendar'[Year] ) VAR CurrentCustomer = 'Data'[Customer] RETURN CALCULATE ( MAX ( 'Data'[UrgencyID] ), FILTER ( 'Data', 'Data'[Customer] = CurrentCustomer && RELATED ( 'Calendar'[Year] ) = TransactionYear ) )
Hi @JarnoVisser
try like this:
Measure = IF ( HASONEVALUE ( Urgencies[Urgency] ), SUMX ( VALUES ( 'Calendar'[Year] ), SUMX ( VALUES ( Customers[Customer] ), IF ( CALCULATE ( MAX ( Data[Urgency ID] ), ALL ( Urgencies ) ) = SELECTEDVALUE ( Urgencies[Urgency ID] ), CALCULATE ( SUM ( Data[Amount] ), ALL ( Urgencies ) ), 0 ) ) ) )
Did I answer your question correctly? Mark my answer as a solution!
Proud to be a Datanaut!
Hi @JarnoVisser,
Add calculated columns:
Rank = IF ( Table2[Urgency] = "High", 1, IF ( Table2[Urgency] = "medium", 2, 3 ) ) Sum amount = IF ( Table2[Rank] = CALCULATE ( MIN ( Table2[Rank] ), ALLEXCEPT ( Table2, Table2[Transaction date].[Year] ) ), CALCULATE ( SUM ( Table2[Amount] ), ALLEXCEPT ( Table2, Table2[Transaction date].[Year] ) ), 0 )
Use a Matrix to display data.
Best regards,
Yuliana Gu
Hi Yuliana,
Thank you for your reply!
It works fine for only one customer. But in my real data I have multiple customers like:
Transaction date | Amount | Urgency | Customer |
1-1-2017 | 50 | high | a |
30-5-2017 | 100 | medium | a |
30-9-2017 | 30 | low | a |
1-1-2018 | 45 | medium | a |
20-2-2018 | 55 | low | a |
1-1-2017 | 50 | low | b |
30-5-2017 | 100 | low | b |
30-9-2017 | 30 | low | b |
1-1-2018 | 45 | medium | b |
20-2-2018 | 55 | high | b |
And with multiple customers it gives no amount for par example customer b in 2017. Do you have a solution for that?
Thanks in advance!
Kind regards,
Jarno
If you follow the Star Schema approach which LivioLanzo showed, then you can also use the below Calculated column HighestUrgencyID in Data table, and create a relationship between Urgency[UrgencyID] & Data[HighestUrgencyID]. This way your measure will be just SUM(Data[Amount]).
HighestUrgencyID = VAR TransactionYear = RELATED ( 'Calendar'[Year] ) VAR CurrentCustomer = 'Data'[Customer] RETURN CALCULATE ( MAX ( 'Data'[UrgencyID] ), FILTER ( 'Data', 'Data'[Customer] = CurrentCustomer && RELATED ( 'Calendar'[Year] ) = TransactionYear ) )
Thank you all! The most easy one even to verify is the solution of Akhil. The syntax of his solution should only be written as follows:
HighestUrgencyID = VAR TransactionYear = RELATED ( 'Calendar'[Year] ) VAR CurrentCustomer = RELATED ('Dim'[Customer] RETURN CALCULATE ( MIN ( 'Data'[UrgencyID] ), FILTER ( 'Data', 'Data'[Customer] = CurrentCustomer && 'Data'[Year] ) = TransactionYear ) )
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 August 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
79 | |
77 | |
46 | |
39 |
User | Count |
---|---|
143 | |
113 | |
64 | |
63 | |
53 |