The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello everyone,
I have a request about a problem i have on my Power BI Desktop.
First of all, i import a table which called PCA with these columns : ANALYT ; CLIENT ; CODEJOUR ; CREDITS ; DEBITS ; DTECRIT ; ETABL ; EXERCICE ; ID_SOCIETE ; LIB2 ; LIGNE ; NUM_COMPT ; NUM_FAC ; PIECE ; REFGESTION ; SECTION ; SOCIETE
I want to add a row on a visual table that i put which balance the amount between Debits and Credits...
For example, if i have 2000 in Debits and 1500 in credits, I would like to create a line where it will have 500 in credits (so i want to balance in the columns which had the less amount between credits and debits and adding the difference between the total of debits and credits).
So i created the follow measure :
As you can see it works well when i didn't put some filters, but when i use the slicers the row didn't create as i want :
I want to adapt the code tha will adapt the row with the filters i put too, for this example, I want a line where i will have an amount of 439.51 in the column MDEBITS (because MDEBIT < DCREDITS).
Thank you for your helping !
If you need more details don't hesitate and tell me !
Solved! Go to Solution.
Hi everyone,
We did it !
So I create a simple measure :
Thank everyone for your helping 🙂
have a great day !
Hi @KevinSV,
I have slightly reviced the measures that What I understand in the images, As I what I belive to ensure your balancing row dynamically adjusts to filters applied via slicers in your Power BI report, you need to modify the logic so that it respects the current filter context. Here's how you can adapt your DAX:
This measure ensures the calculation dynamically respects slicer filters.
BalanceAmount = VAR TotalCredits = SUM(PCA[CREDITS]) VAR TotalDebits = SUM(PCA[DEBITS]) RETURN TotalDebits - TotalCredits
The balancing row should also respect the current filter context by using ADDCOLUMNS and incorporating slicer filters dynamically.
BalanceTable = VAR BalanceAmountValue = [BalanceAmount] VAR TCompte = "48700000" VAR DebitsAmount = IF(BalanceAmountValue > 0, BalanceAmountValue, 0) VAR CreditsAmount = IF(BalanceAmountValue < 0, ABS(BalanceAmountValue), 0) RETURN UNION( -- Original rows from PCA SELECTCOLUMNS( PCA, "LIBELLE", PCA[LIB2], "CODEJOUR", PCA[CODEJOUR], "SOCIETE", PCA[SOCIETE], "TCOMPTE", PCA[NUM_COMPT], "MDEBITS", PCA[DEBITS], "DCREDITS", PCA[CREDITS], "DTECRIT", PCA[DTECRIT], "PIECE", PCA[PIECE], "LIGNE", PCA[LIGNE] ), -- Balancing row ROW( "LIBELLE", "Balancing Line", "CODEJOUR", SELECTEDVALUE(PCA[CODEJOUR]), "SOCIETE", SELECTEDVALUE(PCA[SOCIETE]), "TCOMPTE", TCompte, "MDEBITS", DebitsAmount, "DCREDITS", CreditsAmount, "DTECRIT", SELECTEDVALUE(PCA[DTECRIT]), "PIECE", "BALANCE", "LIGNE", "999" ) )
SUM in BalanceAmount:
SELECTEDVALUE in Balancing Row:
Dynamic Union:
This should solve the issue of balancing rows not adapting to slicer filters. Let me know if further tweaks are needed!
Hello @SacheeTh ,
Thanks for your reply ! Unfortunately it didn't work.
When I filter with the slicers, the balancing line don't create dynamically and so disappear.
Moreover, your measure didn't respect the balance in which column you need to put the amount (between CREDITS and DEBITS).
Here is your code result without the filter :
As you can see there is no balance (i need the amount in the DEBITS amount, i think i have to add this code in the measure : IF(TotalCredits > TotalDebits; TotalCredits - TotalDebits; TotalDebits - TotalCredits).
And when i add filters :
here the balancing line is not created dynamically.
Thanks again for your reply 🙂 !
Hi everyone,
We did it !
So I create a simple measure :
Thank everyone for your helping 🙂
have a great day !
As always, please provide a workable sample data (not an image), your expected result from that and the reasoning behind. You may post a url to sanitized copy of your pbix or an excel file in the cloud.