21. Dynamic Charts: Field Parameters, What-if and Dynamic Top N
21.1 Field Parameters: Switch Measures
Steps in Power BI
- Modeling › New parameter › Fields.
- Name:
Metric Selector. - In Add and reorder fields, tick
[Total Sales],[Total Orders],[AOV],[Avg Delivery Time (mins)]. Drag to reorder. - Keep Add slicer to this page ticked › Create.
- Power BI creates a calculated table Metric Selector and a slicer. Build a line chart: X-axis =
'Date'[Date], Y-axis = Metric Selector (the parameter field). - Select "Avg Delivery Time (mins)" in the slicer. The chart switches measure, and its axis title changes automatically.
- Slicer settings › Selection › Single select On, so one metric is shown at a time. The new button slicer style looks like tabs.
The generated DAX (you can edit the display names in the first argument):
Metric Selector = {
("Sales (₹)", NAMEOF('_Measures'[Total Sales]), 0),
("Orders", NAMEOF('_Measures'[Total Orders]), 1),
("AOV (₹)", NAMEOF('_Measures'[AOV]), 2),
("Avg Delivery (min)", NAMEOF('_Measures'[Avg Delivery Time (mins)]), 3)
}
Field parameters ha navin aani khup upyogi feature aahe. Ekda vaparla ki SWITCH method visraal.
Ravindra Bagale's Tip
A common field-parameter mistake is including measures with different formats (₹ and %) on one axis without checking the format. Keep all measures formatted correctly in Measure tools, and use clear display names in the parameter table. Try it once more, then move on.
Ravindra Bagale's Tip – मराठी
Field parameter मधली एक common चूक म्हणजे format न तपासता वेगवेगळ्या formats चे measures (₹ आणि %) एकाच axis वर घेणं. Measure tools मध्ये सगळे measures बरोबर format करून ठेवा, आणि parameter table मध्ये स्पष्ट display names वापरा. पुन्हा एकदा करून बघा, मग पुढे जा.
Ravindra Bagale's Tip – हिंदी
Field parameter की एक common गलती है format check किए बिना अलग-अलग formats के measures (₹ और %) एक ही axis पर रखना. Measure tools में सभी measures को सही format करके रखो, और parameter table में साफ़ display names इस्तेमाल करो. एक बार फिर करके देखो, फिर आगे बढ़ो.