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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
CharlesMS
Frequent Visitor

How Do I create a variable as static values and put it in the Y coordinate of a graph?

Hello Everyone,

 

I’m reaching out to this knowledgeable community for some assistance or guidance on a matter related to Power BI.

 

I’m attempting to create a variable with static values. For instance, I’d like to set the value as 30 for the current quarter of this year, and then assign a different static value, such as 35, for another quarter of this year.

 

The goal is to use this variable as the Y-axis in a graph.



this is how I get the year and quarter for this quarter

= YEAR(TODAY())
=  QUARTER(TODAY())
 
 

Any help or guidance on how to achieve this would be greatly appreciated.

If you need anything from me just ask!




Thank you in advance! 

3 REPLIES 3
CharlesMS
Frequent Visitor

Hi Albert He, 

thank you for helping out.
The formula that you send me does work but it does not meet my requirements.

The formula does create a  line but it does not get filtered by the filters applied. See images
It should only appear between some dates. 
graph.PNG
I want the line to appear only in the specified range that I have in the filter and also would be nice if you could explain how to add values for other years and quarters. 
So for example if I want to have a number for each quarter and show that number to the graph when that selected filter of date is applied.
2024 Q1 as 0.30 
2024 Q2 as 0.31 
2024 Q3 as 0.32 
2024 Q4 as 0.33 

Do you know why is this the case or how to fix this ? 
Thank you.

Hi @CharlesMS ,
Thanks for the reply, you can create a new filter table and then apply the data from that table to create a slicer. Use max and min to select the range.

Best regards,

Albert He

 

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

v-heq-msft
Community Support
Community Support

Hi @CharlesMS ,
Here some steps that I want to share, you can check them if they suitable for your requirement.
Here is my test data:

vheqmsft_0-1713319518103.png

Create measure

Value = 
VAR _currentYear = YEAR(TODAY())
VAR _currentQuarter = QUARTER(TODAY())
RETURN
IF(
    YEAR(SELECTEDVALUE('Table'[Date])) = _currentYear && QUARTER(SELECTEDVALUE('Table'[Date])) = _currentQuarter,
    30,
    35
)

Final output

vheqmsft_1-1713319578897.png

Best regards,

Albert He

 

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

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.