Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
I am trying to create a Matrix whose rows can be changed by a slicer which is linked to a Parameter (in this I have several Categories).
Since I have two different tables, I need to calculate the difference and show it as an Adjustment in the Matrix. In one table I have the sales till customer level while in the other till country level (differnt data sources).
I have to:
To do so, I have:
By the way, Adjustment has to be shown at the lowest level of my hierarchy (i.e., Customer).
My idea was to manipulate the values in the Matrix by using the code below; I already used it in another dashboard but without the Parameter in the rows, I used just a normal column of the main table and it has worked.
Sales m =
var delta = CALCULATE(SUM('Appended Table'[Sales]),'Appended Table'[Customer] = "Adjustment") - CALCULATE(SUM('Appended Table'[Sales]),'Appended Table'[Customer] <> "Adjustment")
var sales = CALCULATE(SUM('Appended Table'[Sales]), 'Appended Table'[Data source]<> "Tab2")
return
SWITCH(TRUE(),
SELECTEDVALUE(Parameter[Parameter Fields]) = "Adjustment", delta,
COUNTROWS(VALUES(Parameter[Parameter Fields]))>1, sales+delta,
sales)
From my understanding, this is not working as it cannot figure out the value "Adjustment" in the underlying column passing through the Paramenter.
I am sharing a PowerBi example so you can have a look. PowerBi Link
Do you have an ideas?
Solved! Go to Solution.
Hello, I close this post as I figured it out by myself.
Just needed to add an ALLSELECTED in the delta variable of my measure.
Hello, I close this post as I figured it out by myself.
Just needed to add an ALLSELECTED in the delta variable of my measure.
I checked once again and the issue does not seem to be related to the field parameters.
It seems that when I append the additional table I created with "Adjustment " in all the columns to the main one, I cannot manipulate that specific row with this part of the code:
COUNTROWS(VALUES(Parameter[Parameter Fields]))>1, sales+delta,
I am doing like this because otherwise I'd need to replicate all the data in one of the tables (potentially Tab2) many times by adding the label Adjustment for each column for each combination. (e.g. Adjustment for Country and duplicate all the data to have the other columns cobinations, then again with market, etc.)
For the others labels, like FRANCE or POLAND, by using that code I can manipulate the number displayed.
You know why? How can I fix this?
Hello @artur4 ,
check if the field parameters would be a help in your case https://learn.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters
If I answered your question, please mark my post as solution, Appreciate your Kudos 👍
Proud to be a Super User! | |
Hello @Idrissshatila, thaks for your reply.
I did not specify it, I am already using field paramters. This is how I can select different rows in my Matrix. Hoewver, I am not able to modify the rows and the total as I usually do by applying the logic in the code above.
PS
In my original version I am using field parameters also for the columns (i.e., the values of the Matrix which are linked to measures).
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
101 | |
101 | |
87 | |
72 | |
67 |
User | Count |
---|---|
116 | |
109 | |
94 | |
79 | |
72 |