Forum Discussion
find max and min value from same column obtained from dynamic slicer selection and find difference
Dear all,
I need to create a dax for dynamically selecting sites from the slicer and find the difference from max & min selected.
For example, in above screenshot, I have selected 3 sites, out of which max is 316.46 and min is 31.55. so I need a measure
to return the difference and calculate the performance %
dax measure diff = 316.46 - 31.55
performance measure = dax measure diff/max(dax measure diff)
Could you please guide me on this?
Regards,
SC
Here is a sample of the pseudo code:
performance measure = divide(maxx(table,units)-minx(table,units),maxx(allselected(table),units)-minx(allselected(table),units))
you can refine that with SUMMARIZE(ALLSELECTED()) etc. Really depends on how you want to interpret it.
performance measure = var mmax = CALCULATE(max(DataProfile[Units]),allselected(Contacts[Name])) var mmin = CALCULATE(min(DataProfile[Units]),allselected(Contacts[Name])) return mmax-mmin
15 Replies
- lbendlin
Super User
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523- sivarajan21
Post Prodigy
Hi,
Apologise, PFA LINK https://onedrive.live.com/?id=EA584763CE840515%21737&cid=EA584763CE840515
thanks
- lbendlin
Super User
Please check the link, it requires authentication.
- lbendlin
Super User
Here is a sample of the pseudo code:
performance measure = divide(maxx(table,units)-minx(table,units),maxx(allselected(table),units)-minx(allselected(table),units))
you can refine that with SUMMARIZE(ALLSELECTED()) etc. Really depends on how you want to interpret it.
- sivarajan21
Post Prodigy
Hi,
Thank you so much for the response and this works brilliantly for the Data profile. But now the issue I have is with the below graph viz 'Half-Hourly Profile'. This measure is not showing the performance at half hourly level? FYR, please see the below screenshot.
Thanks in advance
- lbendlin
Super User
what is the expected outcome based on the data you provided?
- sivarajan21
Post Prodigy
Hi,
Apologise & PFA link to sample file location
https://onedrive.live.com/?id=EA584763CE840515%21737&cid=EA584763CE840515
I want to give additional info on the same:
The Relationship is and the fields used in dax measure are below:
My requirement is, I want to find max & min and show the difference in tooltip. for example, when i select 2 sites from slicer as shown in below screenshot
it should return 263.31-215.11= 48.2 in site variance tooltip but currently it shows zero.
but what i observed is when i turn this into table visual instead of line chart,it shows the difference in total level as below
Can you please guide me on this issue? How can show this difference total
in line chart tooltip?
Thanks in advance