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.
Hi everyone,
My ambition is to write a measure that calculates the difference between two selected time periods using a filter slicer.
After some googling around, I found a solution that is ALMOST working. The solution is using MAX and MIN formulas in variables
to calculate difference between the max and min value selected. https://www.fourmoo.com/2019/05/08/dax-calculating-the-difference-between-2-selections-on-a-slicer/
Based on the solution I was given, I created the following:
First, I thought I had made it to work. But then I realized that the measure is always calculating the absolute difference, not paying attention to the order of the time periods.
In other words, I want the measure to always take the MAX value to always represent the latest time period selected and the MIN value to always represent the time period most long ago selected.
In the example I have attached a picture where you can see the error. I get a positive number when I should get a negative number.
Here is the link to my screenshots: https://drive.google.com/drive/folders/1FbNNMIYHnagfuaLxRez3cEXBMZC8NRrR?usp=sharing
Does anyone have any idea how I can re-write the measure? I was thinking of using some kind of RANK formula, but then again I am not so good with DAX.
Any help greatly appreciated 😃
/Rasmus
Solved! Go to Solution.
@Anonymous
You may refer to the post below.
Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Sample data as text.
When you take diff in measure, you need to take care of row context. Please refer to this blog: https://community.powerbi.com/t5/Community-Blog/Decoding-Direct-Query-in-Power-BI-Part-2-Date-Differ...
True for import. See how order number is used as context for difference
Thanks for replying. When you see me measure,how would you re-write the DAX? I am not sure I am following your example.
Certainly. First of all, did you see the two pictures I posted in the link?
There are only few columns involved in this issue.
There are two tables related to this issue in my dataset: "FIN_LogUnits Data" (data table) and "Time_Lookup" (Own constructed calander table).
In "FIN_LogUnits Data" the two columns related to this:
"Fin_Log_Period" (data column with values) and "TIME" which is the key-column that goes to "Time_Lookup".
In "Time_Lookup", except for "TIME" there is "Period" which I am filtering on in this case.
Thanks a lot for showing an interest to help! 🙂
@Anonymous
You may refer to the post below.
This methodology worked!
Thanks a lot!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
99 | |
88 | |
70 | |
62 |
User | Count |
---|---|
151 | |
120 | |
103 | |
87 | |
68 |