Forum Discussion
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?
This i what it looks like when i choose 1st quarter:
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.
11 Replies
- darentengmfsPost Prodigy
- JensejHelper V
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
- darentengmfsPost Prodigy
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.
- darentengmfsPost Prodigy
- JensejHelper V
Yeah i dont have different budget (target) for different months. It's the yearly budget / 12
- darentengmfsPost Prodigy
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}
When the column is created, click the double arrow and choose Expand to New Rows
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)