The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi,
I have a requirement where I have to show the target line graph in ascending order. I have to take an average of the selected months revenue and multiply that with the selected months count. If I select June, July, and Agust, then It should consider the count of june as 1, july as 2 and August as 3. My average is a Pure measure. I don't need a column for target. I want to just create a measure for this caculation and use it in the line graph.
Below is the sample of what I am looking for.
Thanks in advance:)
@Supritha1594, you can modify the SWITCH function to make it more flexible. Here's a revised approach using the following DAX formula:
Target =
VAR SelectedMonths = VALUES('Table'[Month])
RETURN
AVERAGE([Revenue]) *
SUMX(
FILTER(ALL('Table'[Month]), 'Table'[Month] IN SelectedMonths),
RANK.EQ('Table'[Month], 'Table'[Month], 0)
)
This way, the formula dynamically adjusts to any range of selected months. You can use this measure in his line graph to achieve the desired results.
@Supritha1594 you can navigate to the “Fields” pane. Locate the table housing the revenue data you wish to utilize. Proceed to the “Modeling” tab and select the “New Measure” button.
In the formula bar, input the following formula:
Target = AVERAGE([Revenue]) * SWITCH(SELECTEDVALUE('Table'[Month]), "June", 1, "July", 2, "August", 3, 0)
Ensure to rename “Table” with the accurate name of the table containing the month data, “Revenue” with the appropriate column name for revenue data, and “Month” with the column name for month data. Once done, save the measure and integrate it into your line graph.
This measure will calculate the average revenue for the selected months and multiply it by the number of months chosen. The SWITCH function will return 1 for June, 2 for July, 3 for August, and 0 for any other month. This will ensure that the count is correct for the selected months.
@DallasBaba thank you for your response!
But everytime it won't be june, july, and august. User may select any range of months. For example if an user selects January and february then it should be 1 for january and 2 for february. Is it possible in that way?