Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Laocsulak
Helper I
Helper I

How to create measure and axis based on parameter/slicer selection

Hello,


I have created a bar chart where X axis is month or quarter based on parameter selection. Also, I have created a measure that shows month over month variation, but I would like that the measure shows quarter over quarter variation when the quarter is selected for X axis parameter. Anyone know how to solve this problem?

 

Laocsulak_0-1673568286642.png

Laocsulak_1-1673568353475.png

Measure created to show month over month variation:

TPV MoM = 

TPV MoM =
VAR __PREV_MONTH =
 CALCULATE ( SUMX(Sheet1,Sheet1[amount]) , DATEADD ( 'Calendario'[Date], -1, MONTH ) )
RETURN
 IF (
 ISBLANK ( __PREV_MONTH ),
 BLANK (),
 ( SUMX(Sheet1,Sheet1[amount])  ) / __PREV_MONTH - 1
 )
 
 
Parameter created to show month or quarter in X axis:
Parameter = {
    ("Periodo", NAMEOF('Calendario'[Periodo]), 0),
    ("Trimestre", NAMEOF('Calendario'[Trimestre]), 1)
}

 

Dummy example:

https://drive.google.com/drive/folders/1Cssqngz5G645NpiZRjnTQ74oxBYoj6db?usp=sharing

 

Thanks in advance!

 

3 REPLIES 3
v-tangjie-msft
Community Support
Community Support

Hi @Laocsulak ,

 

 Please try to create a measure. 

 

infectionSwitchStatement = 
var Infection =
SWITCH (
    SELECTEDVALUE('Eje X'[X Axis Fields]),
    "Mensual", 'metricas'[TPV MoM],
    "Trimestral", 'metricas'[TPV QoQ]
    
)
return Infection

 

 

Please refer to the following document for more information.

The workaround of using the measure as axis in the... - Microsoft Power BI Community

Field Parameters in Power BI - Microsoft Power BI Community

Measure Calculation Using Dynamic Column Names - Microsoft Power BI Community

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Thanks for the answer, but what I need to see is the percentage variation month over month and quarter over quarter, and this createad measure is not showing any value.

amitchandak
Super User
Super User

@Laocsulak , Refer How Switch measure in field parameter

Switch TOPN with Field Parameters: https://amitchandak.medium.com/switch-topn-with-field-parameters-299a0ae3725f

 

Power BI Field Parameters — A Quick way for Dynamic Visuals: https://amitchandak.medium.com/power-bi-field-parameters-a-quick-way-for-dynamic-visuals-fc4095ae9af...
Power BI Field Parameters- Measure Slicer and Axis/Dimension slicer: https://youtu.be/lqF3Wa1FllE

 

Others
Field Parameters- Conditional Formatting: https://amitchandak.medium.com/field-parameters-conditional-formatting-517aacc23fdf

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors