Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
The situation is easy to solve via Power Query, but I'd love to know how to do this in DAX.
Say I have the below table:
I want to sum the Spend column: SUM(Spend)
Only when RuleviolationID = 7: CALCULATE(SUM(SPEND), RuleViolationID = 7)
So that's all very simple.
But see how the PaymentIDs have duplicates? I only want to sum the Spend 1x per each instance of a PaymentID.
I was thinking of using CALCLUATETABLE to pull a version of the table where RuleViolationID = 7, And then using VALUES to only grab unique values of the PaymentID, but - obviously that doesn't work. It makes me think virtual tables would be the way to go, though.
It's easy to just pull a custom version of the table in Power Query, but is there a good way to work this in DAX?
Hi @mmace1
You may try to create a table with SUMMARIZE Function. For example:
Table =
SUMMARIZE (
FILTER ( Table1, Table1[RuleViolationID] = 7 ),
Table1[PaymentID],
"Spend", SUM ( Table1[Spend] )
)
Regards,
Cherie
Thanks - wouldn't summarize by the paymentID, result in duplicate payment IDs being counted more than 1x though?
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 43 | |
| 39 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 67 | |
| 63 | |
| 30 | |
| 30 | |
| 23 |