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
Hi All,
I'm having some trouble with a calculation here as the "total" in the below visual does not represent the average of what is presented, which is what I would like. Essentially I would like to take an average of what is in the "Consumer Preference Score" column and divide each consumer preference score by that average to get the "Consumer Preference Index". As you can see, right now it does not look like it's being calculated correctly.
Any assistance would be appreciated!
Thanks,
Maggie
Solved! Go to Solution.
Hi all,thanks for the quick reply, I'll add more.
Hi @Anonymous ,
Try this
Measure =
VAR _selection = SELECTEDVALUE('Field Select Parameter'[Type])
VAR _table1 = ADDCOLUMNS(ALL('Product Hierarchy'[Category]),"Result",[Consumer Preference Score])
VAR _table2 = ADDCOLUMNS(ALL('Product Hierarchy'[Sub-Category]),"Result",[Consumer Preference Score])
RETURN
SWITCH(TRUE(),
_selection = "Category",DIVIDE([Consumer Preference Score],AVERAGEX(_table1,[Result])),
_selection = "Sub-Category",DIVIDE([Consumer Preference Score],AVERAGEX(_table2,[Result]))
)
Final output
Best Regards
Hi all,thanks for the quick reply, I'll add more.
Hi @Anonymous ,
Try this
Measure =
VAR _selection = SELECTEDVALUE('Field Select Parameter'[Type])
VAR _table1 = ADDCOLUMNS(ALL('Product Hierarchy'[Category]),"Result",[Consumer Preference Score])
VAR _table2 = ADDCOLUMNS(ALL('Product Hierarchy'[Sub-Category]),"Result",[Consumer Preference Score])
RETURN
SWITCH(TRUE(),
_selection = "Category",DIVIDE([Consumer Preference Score],AVERAGEX(_table1,[Result])),
_selection = "Sub-Category",DIVIDE([Consumer Preference Score],AVERAGEX(_table2,[Result]))
)
Final output
Best Regards
@Anonymous
We don´t know much about your model and the context where the measure is executed.
Therefore it´s very hard to develop a measure that works with your model and report.
Can you share the pbix?
Hi @pcoley - completely understand.
Here is the PBIX: https://drive.google.com/file/d/1MEiWn62BLC5gDQNDsg0Ti3UyQ26WP2zA/view?usp=sharing
Please let me know if you have any issues with access. Thanks! Maggie
@Anonymous
Please try with this measure:
Avg. Consumer Preference Score =
SWITCH(values('Field Select Parameter'[Selection Parameter Order]),
0 ,CALCULATE ([Consumer Preference Score], ALLSELECTED('Product Hierarchy'[Category])),
1,CALCULATE ([Consumer Preference Score], ALLSELECTED('Product Hierarchy'[Sub-Category])))I hope this helps, if so please accept the solution.
👉kudos are welcome😁
@Anonymous - did we resolve your issue? If we did, please select the appropriate solution, it helps with visibility for others and for SuperUsers to keep their status! Thanks!
@Anonymous - please provide the DAX you have already used.
Yes, so Consumer Preference Score is this:
Ok, if you want an average of the scores in the visual you should use:
AVERAGEX( ALLSELECTED('Nielsen (excl dist)'), [Consumer Preference Score])
If this works, please accept as the solution.
Thanks so much for getting back to me. It looks like when I take this approach I get the following:
In this instance, I would expect the average to be ~16. The sub-category column being used comes from a parameter. Any help would be appreciated!
@Anonymous
Please try with the next options:
-->Please change in the 1st code "TransactionTable" with the name of your transactionTable
To calculated the average of the subcaategories including the total please use the next measure:
Avg. Consumer Preference Score :=
AVERAGEX(
VALUES( 'Nielsen (excl dist)' ),
CALCULATE(
AVERAGEX(
TransactionTable, //please place here your transactionTable
[Consumer Preference Score]
)
)
)If you want to have all the selected one please use this measure:
MeasureALLSELECTED =
CALCULATE(
[Avg. Consumer Preference Score],
ALLSELECTED( 'Nielsen (excl dist)' )
)and if you want to have all the subcategories no matter if they are selected please use this measure:
MeasureALL =
CALCULATE(
[Avg. Consumer Preference Score],
ALL( 'Nielsen (excl dist)' )
)I hope this help if so pleace mark as a solution. kudos are welcome😀
Hi @pcoley
Thank you very much for your input. With this solution I get the following (see screenshot). The average figure I would expect would be 16.
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.
Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.
| User | Count |
|---|---|
| 6 | |
| 6 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 22 | |
| 10 | |
| 10 | |
| 7 | |
| 5 |