Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello,
Here is the original table:
I need a calculated column that will for each category display the difference in rating from the base rating for that category.
Here are what the column results would be:
Thank you,
Bob
Solved! Go to Solution.
hello @bob57 ,
pelase try :
Result =
var _Currentcategory=Table1[Category Id]
var _Previousrating= MINX(FILTER(Table1,Table1[Rating]<EARLIER(Table1[Rating]) && Table1[Category Id]=_Currentcategory),Table1[Rating])
var _result=Table1[Rating]-_Previousrating
return IF(ISBLANK(_Previousrating),0,_result)
if you find this helpful, please consider accepting it as a solution and a kudos is appreciated
I jumped the gun. There is still one small issue. The calculation must be relative to the Base. So with Category Id 3, record Id = 8 should be 0 (Base = TRUE) and record Id = 9 should be -1.4 (47.6 - 49). So sorry for not being more thorough at first glance.
is this the desired result?
Result =
var _Currentcategory=Table1[Category Id]
var _Previousrating= MINX(FILTER(Table1,Table1[Rating]<EARLIER(Table1[Rating]) && Table1[Category Id]=_Currentcategory && Table1[Base] = "true"),Table1[Rating])
var _Previousrating2= MINX(FILTER(Table1,Table1[Rating]>EARLIER(Table1[Rating]) && Table1[Category Id]=_Currentcategory && Table1[Base] = "true"),Table1[Rating])
var _result=Table1[Rating]-_Previousrating -_Previousrating2
return IF(Table1[Base]="true",0,_result)
Yes. That does it. Thanks you!
This solution works beautifully! Now I have to figure out how it works. Thank you so much!
basically, in the MINX,in table selection , you want to filter the table first to show it - 1 row
hence using the earlier , since we used eralier([rating]) this will show 1 row before, the earlier can be used with ealier([rating],2) to show 2 rows before...
hence we filtered the table to show the earlier result and substract current wit hearlier ,then we want to go from down to up so we use MINX to pick up the last one instead of going from up to down, in that case you will use MAXX like the example below:
hello @bob57 ,
pelase try :
Result =
var _Currentcategory=Table1[Category Id]
var _Previousrating= MINX(FILTER(Table1,Table1[Rating]<EARLIER(Table1[Rating]) && Table1[Category Id]=_Currentcategory),Table1[Rating])
var _result=Table1[Rating]-_Previousrating
return IF(ISBLANK(_Previousrating),0,_result)
if you find this helpful, please consider accepting it as a solution and a kudos is appreciated
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
21 | |
21 | |
19 | |
13 | |
12 |
User | Count |
---|---|
42 | |
28 | |
23 | |
22 | |
22 |