Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreThe FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now
Hi Power BI Experts,
I am new to Power BI. I have two dimensions - Product Estimated price and Product Actual price from different source.
I am trying to create a chart use TopN to show those two dimensions. Following is my TopN(Actual Price) DAX-
Solved! Go to Solution.
Hi @QN278 ,
You can try step like below:
create two slicer table:
create below measure:
M_actual =
var actual_ = CALCULATE (
MAX ( Actual[Products] ),
KEEPFILTERS (
TOPN ( SELECTEDVALUE ( 'TopN'[Topn] ), ALL ( Actual ), Actual[Prices] )
)
)
return if(MAX(Estimated[Products]) = actual_ ,MAX(Estimated[Price]),BLANK())M_estimated =
var estimated_ = CALCULATE (
MAX ( Estimated[Products] ),
KEEPFILTERS (
TOPN ( SELECTEDVALUE ( 'TopN'[Topn] ), ALL ( Estimated ), Estimated[Price] )
)
)
return if(MAX(Actual[Products]) = estimated_ , MAX(Actual[Prices]),BLANK())M1 = CALCULATE (
MAX ( Actual[Prices] ),
KEEPFILTERS (
TOPN ( SELECTEDVALUE ( 'TopN'[Topn] ), ALL ( Actual ), Actual[Prices] )
)
)
M2 = CALCULATE (
MAX ( Estimated[Price] ),
KEEPFILTERS (
TOPN ( SELECTEDVALUE ( 'TopN'[Topn] ), ALL ( Estimated ), Estimated[Price] )
)
)result1_ =
var cur_ = SELECTEDVALUE(slicer[slicer])
return SWITCH(cur_, "Actual",[M1], "Estimated",[M_estimated])
result2_ =
var cur_ = SELECTEDVALUE(slicer[slicer])
return SWITCH(cur_, "Actual",[M_actual], "Estimated",[M2])
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @QN278 ,
You can try step like below:
create two slicer table:
create below measure:
M_actual =
var actual_ = CALCULATE (
MAX ( Actual[Products] ),
KEEPFILTERS (
TOPN ( SELECTEDVALUE ( 'TopN'[Topn] ), ALL ( Actual ), Actual[Prices] )
)
)
return if(MAX(Estimated[Products]) = actual_ ,MAX(Estimated[Price]),BLANK())M_estimated =
var estimated_ = CALCULATE (
MAX ( Estimated[Products] ),
KEEPFILTERS (
TOPN ( SELECTEDVALUE ( 'TopN'[Topn] ), ALL ( Estimated ), Estimated[Price] )
)
)
return if(MAX(Actual[Products]) = estimated_ , MAX(Actual[Prices]),BLANK())M1 = CALCULATE (
MAX ( Actual[Prices] ),
KEEPFILTERS (
TOPN ( SELECTEDVALUE ( 'TopN'[Topn] ), ALL ( Actual ), Actual[Prices] )
)
)
M2 = CALCULATE (
MAX ( Estimated[Price] ),
KEEPFILTERS (
TOPN ( SELECTEDVALUE ( 'TopN'[Topn] ), ALL ( Estimated ), Estimated[Price] )
)
)result1_ =
var cur_ = SELECTEDVALUE(slicer[slicer])
return SWITCH(cur_, "Actual",[M1], "Estimated",[M_estimated])
result2_ =
var cur_ = SELECTEDVALUE(slicer[slicer])
return SWITCH(cur_, "Actual",[M_actual], "Estimated",[M2])
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I found a way to solve my problem, first drag my expected field (For example : actual price) to product names fielter value on the chart. Then put these two dimensions into the Y-axis chart and it was done. The only problem is that I can't dynamically adjust the value of TopN.
Hi @v-kongfanf-msft ,
I can't find a place to upload pbix data.
So I upload the picture.
I have 3 different sources. They use product names to manage relationship.
I input some test data.
My desire results is when i select estimate filter.The chart show as picture 1.
And when i choose another one actual filter.The chart show as picture 2.
Relationship
Test data
1
2
Hi @QN278 ,
You can create the following formulas by selecting one of them first and then sorting them by TopN on a chart.
SelectedMeasure =
VAR SelectedMeasure =
SELECTEDVALUE ( 'Slicer'[MeasureSelection] )
RETURN
SWITCH (
SelectedMeasure,
"Estimated Price", [Measure_estimate],
"Actual Price", [Measure_actual]
)
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous
Thank you for your help.
Is it possible to sort the TopN at the same time on one chart after selecting one of measure?
For example if i choose Estimated price measure about Top5.
The chart should show the expected prices of the products base on Top5, then their actual price.
The purpose of displaying them simultaneously is to facilitate comparison.
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 |
|---|---|
| 53 | |
| 40 | |
| 38 | |
| 19 | |
| 18 |
| User | Count |
|---|---|
| 70 | |
| 69 | |
| 34 | |
| 33 | |
| 30 |