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 Team, I am looking for solution for this issue.
I would want to calculate the difference between each day under each county. Wondering how to achieve this. Please advised. Thanks.
Solved! Go to Solution.
Hi guys,
I solved the issue via this method. https://community.powerbi.com/t5/Desktop/Dax-to-Sql-Windowing-Lag-function-Over-partition-by-equival...
Hi guys,
I solved the issue via this method. https://community.powerbi.com/t5/Desktop/Dax-to-Sql-Windowing-Lag-function-Over-partition-by-equival...
Hi @ronlolololo
I'm so glad you have solved your porblem. And thanks for sharing this method for us to solve this issue.
Please mark your reply as a solution.
Best Regards,
Rico Zhou
Hi,
Try this calculated column formula
=Table[DateKey]-calculate(max([datekey]),filter(table,table[County Name]=earlier(table[County Name])&&table[DateKey]<earlier(table[DateKey])))
Ensure that your Datekey column is formatted as a Date field.
Hope this helps.
Thanks for the response!
I typed in the code and it tured out this way. Let me know if I did anything wrong. Thanks.
It looks fine to me. Share the link from where i can download your PBI file.
I see you have an index column - that's good.
1. for each line in your visual (the filter context) get the county name
var cn = SELECTEDVALUE(table[County Name])
2. get the current index
var id = SELECTEDVALUE(table[Index])
3. get the maximum index for the same county that is smaller than your current index
var prev_id=CALCULATE(MAX(table[Index]),ALLSELECTED(table),table[County Name]=cn,table[Index]<id)
4. lastly, get the value for that index.
var val = CALCULATE((whatever),ALLSELECTED(table),table[Index]=prev_id)
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 |
---|---|
110 | |
95 | |
76 | |
65 | |
51 |
User | Count |
---|---|
146 | |
109 | |
106 | |
88 | |
61 |