Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Dear Community, I have following these table:
1. table dim_structure_report:
2. table gross_sale_test_data:
3. No relationship.
Then i created a Matrix visualization:
with config:
and measure 0.select_measure_test
0.select_measure_test =
VAR SelectedLevel = SELECTEDVALUE(dim_structure_report[metric])
VAR SelectedSubLevel = SELECTEDVALUE(dim_structure_report[sub_1])
VAR NumSubLevels =
CALCULATE(
DISTINCTCOUNT(dim_structure_report[sub_1]),
ALL(dim_structure_report),
dim_structure_report[metric] = SelectedLevel
)
VAR MaxSubLevelValue =
CALCULATE(
MAXX(dim_structure_report, [sub_1]),
ALL(dim_structure_report),
dim_structure_report[metric] = SelectedLevel
)
RETURN
SWITCH(
TRUE(),
SelectedSubLevel = "mkt_promotion", // Higher level, specific metric
[promotion],
SelectedLevel = "gross_sale" && NumSubLevels > 1, // 'gross_sale' metric with multiple sub_1 levels
BLANK(),
SelectedSubLevel = "gross_sale", // 'gross_sale' sub_1 level
IF(NumSubLevels = 1, [gross_sale], MaxSubLevelValue),
SelectedSubLevel = "mkt",
[mkt],
SelectedSubLevel = "promotion",
[promotion],
SelectedSubLevel = "ads_spend",
[mkt] + [promotion],
SelectedSubLevel = "%ads_spend",
DIVIDE(([mkt] + [promotion]), [gross_sale]),
SelectedSubLevel = "profit",
[gross_sale] - ([mkt] + [promotion]),
SelectedSubLevel = "%profit",
DIVIDE(([gross_sale] - ([mkt] + [promotion])), [gross_sale]),
BLANK() // Default case
)
But the result is not my expecting, so i want my results to be like this in each situation:
1. If metric only have 1 sub_1 value, that sub_1 value will not show up when click on (+) (-) expand or collapse, and the metric value will be like its sub_1 value.
2. If metric has many sub_1 value, that sub_1 value will show up when click on (+) (-) expand or collapse, and the metric value will be like its sum of (sub_1 value).
3. If metric has many sub_1 value in clude percentage %, that sub_1 value will show up when click on (+) (-) expand or collapse, and the metric value will be like a specific measure like the line CM Sell In External.
I have searched some method, and found this keywork switch(), isinscope(), if(). But dont know how to use.
I hope some one experienced in this can rewrite my measure to make it works and this will help me so much.
Thank you and have a good day.
My attached file:
Hi @hungcht ,
for this you need a parent child hierarchy:
https://www.daxpatterns.com/parent-child-hierarchies/
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsUser | Count |
---|---|
89 | |
75 | |
69 | |
65 | |
58 |
User | Count |
---|---|
103 | |
94 | |
75 | |
61 | |
58 |