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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Jensej
Helper V
Helper V

Using values from a Visual filter in a measure

Hello! 

 

So i have a yearly Target Amount stored in a table. 15 780.-

 

Now i have a visual where my target value is 15 780.-. In my visual im able to filter the months if i for example want to look at  first quarter i check 1,2,3,4 from month. 

 

The problem is that my Target stays at 15 780.- but i want it to also change when i choose less months. 

 

Therefor i want to make a Measure where i say the Target is 15 780.- from start with all 12 months but if only 6 is selected the Target has to be 7890.-. 

 

Is there some way to get the selected month/months into a measure? 

 

Jensej_0-1600784697658.png

 

This i what it looks like when i choose 1st quarter:

 

Jensej_0-1600784943692.png

 

 

1 ACCEPTED SOLUTION

@Jensej 

 

I apologize for the misplaced " in the formula.

 

Before you create the date column, click on Month, change the data type to text. Same thing goes to year. Then, you create the date column, after that, change the data type of the date column to date.

View solution in original post

11 REPLIES 11
darentengmfs
Post Prodigy
Post Prodigy

@Jensej 

 

Are you trying to split the values evenly by month?

Yeah i dont have different budget (target) for different months. It's the yearly budget / 12

@Jensej 

 

If that's the case, I would use Power Query to insert months into your data.

 

Go to Power Query > Add Custom Column > Enter the formula: {1..12}

darentengmfs_0-1600788078978.png

 

When the column is created, click the double arrow and choose Expand to New Rows

darentengmfs_1-1600788132397.png

 

After that, you can either add a new column using Power Query or in DAX for your columns, e.g. Monthly Apple = [Apple]/12

This will give you the amount for each month.

 

You now have your month numbers that you can use to filter. If you wish to convert your month number into month name, please refer to the link below.

 

https://stackoverflow.com/questions/42964605/how-to-get-month-name-from-month-number-in-power-bi

 

If you wish to convert month number into Quarter number, use the following formula:

Quarter = "Q" & ROUNDUP('Table'[Month]/3,0)

Hi @darentengmfs 

 

Thanks for answers.

 

So i did what you said.  Here is my how my Table look like atm. 

Jensej_0-1600865288173.png

 

I also connected the month and year to my date table

 

Jensej_1-1600865489604.png

 

Why does my Sum of AHT Grün not show only the Sum of 1st quarter? It's showes the whole year.

 

Jensej_2-1600865582147.png

 

 

 

@Jensej 

 

That's because the relationship isn't done right. If you could see the dotted lines in your relationship view, that means the relationship is not active. You cannot have 2 different relationships for the same 2 tables.

 

What I will do next is concatenante your month number to your year with a specific date in your data table. I would do this in Power Query by adding a new column.

 

Rest of the World -

Date:  "1/" & [Month] & "/" & "[Year]

 

OR

 

North America Version -

Date: [Month] & "/1/" & [Year]

 

Use the formula depending on your date formats. Apply the query, and use the newly created column in for your relationship between data table and date table.

Tried this one 

 

Rest of the World -

Date:  "1/" & [Month] & "/" & "[Year]

 

It shows an error right away so i took the " before the Year away so i could save. Like this

Rest of the World -

Date:  "1/" & [Month] & "/" & [Year]

 

Now i get an error saying. Expression.Error: We cannot apply operator & to types text and number...

@Jensej 

 

I apologize for the misplaced " in the formula.

 

Before you create the date column, click on Month, change the data type to text. Same thing goes to year. Then, you create the date column, after that, change the data type of the date column to date.

darentengmfs
Post Prodigy
Post Prodigy

@Jensej 

 

Is the relationship between the months table and the amount table defined?

Hi @darentengmfs 

 

No it's just a table with single budget amounts without any other information ( No dates ) 

 

Like this: 

Apples | Pineapples | Pear

 300     |       700      |   450

@Jensej 

 

If your data does not have date values or anything that is related to dates, Power BI will not know what dates those are in.

 

@darentengmfs  I understand but isnt possible at all to see what i choose in the Visual Filter and use these inputs in a measure? 

 

 

 

Measure  = 

Variable = Target/12

 

CALCULATE( SUM(SELECTEDMONTHS)*Variable)

 

 

Something like this

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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