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.
Dear All,
Could you help me show how to minus between 2 column previous Measure in PowerBI.
Source:
Destination desire
M.ExpectedPre = M.ExpectedValue - Previous(M.Duration)
Any column above are measure type.
Many thanks.
Solved! Go to Solution.
Hi @ptkhoa2110
I update my Calculated Column and Measure in your Sample and hope this may help you.
Rank column:
C.Rank = RANKX(FILTER(DemoTracking,DemoTracking[ITEMCODE] = EARLIER(DemoTracking[ITEMCODE])),DemoTracking[TransferID],,ASC,Dense)
Measure:
M.ExpectedPre =
VAR _Pre =
CALCULATE (
[M.ExpectedValue],
FILTER ( ALL(DemoTracking) ,DemoTracking[ITEMCODE]=MAX(DemoTracking[ITEMCODE])&& DemoTracking[C.Rank] = MAX ( DemoTracking[C.Rank] ) - 1 )
)
RETURN
IF ( _Pre = BLANK (), BLANK (), _Pre - [M.Duration] )
Result:
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @ptkhoa2110
Due to I don't know your data model, so I have to build a sample table to have a test.
Add a Rank column in this Table.
Rank = RANKX('Table','Table'[M.To Date],,ASC,Dense)
Due to M.ExpectedPre = M.ExpectedValue - Previous(M.Duration) are all measures, so build measures.
M.Duration = SUM('Table'[3])
M.ExpectedValue = SUM('Table'[4])
M.ExpectedPre =
VAR _Pre =
CALCULATE (
[M.ExpectedValue],
FILTER ( ALL ( 'Table' ), 'Table'[Rank] = MAX ( 'Table'[Rank] ) - 1 )
)
RETURN
IF ( _Pre = BLANK (), BLANK (), _Pre - [M.Duration] )
Result:
You can download the pbix file from this link: Minus 2 measure previous value
If this reply still couldn't help you solve your problem, please show me your data model and you calculate logic of these three columns. Or you can provide me with your pbix file by you OneDrive for Business. And this may make it easier for me to understand your calculate logic.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Dear @v-rzhou-msft ,
Please focus here:
Please download link: https://lfshare-my.sharepoint.com/:u:/g/personal/khoaphan_idsmed_com/EZ0IKgyAlZFHinX3npczy2IBpxDl_uA...
Many thanks RicoZho,
Hi @ptkhoa2110
I update my Calculated Column and Measure in your Sample and hope this may help you.
Rank column:
C.Rank = RANKX(FILTER(DemoTracking,DemoTracking[ITEMCODE] = EARLIER(DemoTracking[ITEMCODE])),DemoTracking[TransferID],,ASC,Dense)
Measure:
M.ExpectedPre =
VAR _Pre =
CALCULATE (
[M.ExpectedValue],
FILTER ( ALL(DemoTracking) ,DemoTracking[ITEMCODE]=MAX(DemoTracking[ITEMCODE])&& DemoTracking[C.Rank] = MAX ( DemoTracking[C.Rank] ) - 1 )
)
RETURN
IF ( _Pre = BLANK (), BLANK (), _Pre - [M.Duration] )
Result:
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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 |
---|---|
106 | |
94 | |
77 | |
65 | |
53 |
User | Count |
---|---|
145 | |
105 | |
104 | |
90 | |
63 |