Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Combining measures

Hi,

I have 2 measures as follows,

Debit  =

SUMX (
    SUMMARIZE (
        RP_TR_TRANSACTION_DETAILS,
        RP_TR_TRANSACTION_DETAILS[As of Date],
        RP_TR_TRANSACTION_DETAILS[account_cd],
        "TotalCount", if([Sum-Amount]>0,[Sum-Amount],blank())
    ),
    [TotalCount]
)
 
Credit =
SUMX (
    SUMMARIZE (
        RP_TR_TRANSACTION_DETAILS,
        RP_TR_TRANSACTION_DETAILS[As of Date],
        RP_TR_TRANSACTION_DETAILS[account_cd],
        "TotalCount", if([Sum-Amount]<0,[Sum-Amount],blank())
    ),
    [TotalCount]
)
 
I want them to be combined into a single measure.
Can this be done?
7 REPLIES 7
amitchandak
Super User
Super User

@Anonymous , Not very clear Try like

 

SUMX (
SUMMARIZE (
RP_TR_TRANSACTION_DETAILS,
RP_TR_TRANSACTION_DETAILS[As of Date],
RP_TR_TRANSACTION_DETAILS[account_cd],
"TotalCount", [Sum-Amount]
),
[TotalCount]
)
or
SUMX (
SUMMARIZE (
RP_TR_TRANSACTION_DETAILS,
RP_TR_TRANSACTION_DETAILS[As of Date],
RP_TR_TRANSACTION_DETAILS[account_cd],
"TotalCount", abs([Sum-Amount])
),
[TotalCount]
)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

@amitchandak 

I'll make it more clear. Created a measure

Sum-Amount = SUMX (
    SUMMARIZE (
        RP_TR_TRANSACTION_DETAILS,
        RP_TR_TRANSACTION_DETAILS[As of Date],
        RP_TR_TRANSACTION_DETAILS[account_cd],
        "TotalCount", Sum(RP_TR_TRANSACTION_DETAILS[Amount])
    ),
    [TotalCount]
)
Next i need division of this measure >0 and < 0 which should be categorized as Debit and Credit respectively. Right now i'm using 2 measures as mentioned in my previous post. Is there a way that i can calculate this Debit/Credit using a single measure?

Here is one way that might work for you.

 

Credit Debit Ration =

var summarytable = SUMMARIZE (
        RP_TR_TRANSACTION_DETAILS,
        RP_TR_TRANSACTION_DETAILS[As of Date],
        RP_TR_TRANSACTION_DETAILS[account_cd],
        "TotalCount", Sum(RP_TR_TRANSACTION_DETAILS[Amount])
    )

var credit = SUMX (
    Filter(summarytable,[TotalCount] >0)
    [TotalCount]
)

var  = debit = SUMX (
    Filter(summarytable,[TotalCount] <0)
    [TotalCount]
)

return credit/debit

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

@@mahoneypat @amitchandak @darlove @Greg_Deckler

Thank you for the DAX. But its not working as expected. The values are way off the actual values.

 

Is there any other way in which i can combine both the measures (Credit or Debit) into a single ome.

Any help would be appreciated.

dax
Community Support
Community Support

Hi @Anonymous , 

I am not clear about your requirement, if possible could you please inform me more detailed information(such as your expected output and your sample data (by OneDrive for Business))? Then I will help you more correctly.

Please do mask sensitive data before uploading.

Thanks for your understanding and support.
Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@Anonymous , Can you share sample data and sample output. Looking at formula difficult to say now.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

I'll make it more clear. Created a measure

Sum-Amount = SUMX (
    SUMMARIZE (
        RP_TR_TRANSACTION_DETAILS,
        RP_TR_TRANSACTION_DETAILS[As of Date],
        RP_TR_TRANSACTION_DETAILS[account_cd],
        "TotalCount", Sum(RP_TR_TRANSACTION_DETAILS[Amount])
    ),
    [TotalCount]
)
Next i need division of this measure >0 and < 0 which should be categorized as Debit and Credit respectively. Right now i'm using 2 measures as mentioned in my previous post. Is there a way that i can calculate this Debit/Credit using a single measure?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.