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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Anonymous
Not applicable

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

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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