Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
frmtaat
New Member

Caluclated column for variance b/w periods

Dear All,

 

I would like to add a new coulmn to a matrix to see the delta between the periods. Let's say i have the following raw data:

 

PeriodGLAmount
110050
1200100
210060
2200200

 

I have created the following matrix:

 

Column: Period; Raw: GL; Value: Amount. Now it looks like this:

 

 12DELTA
100*5060=60-50
200*100200=200-100

 

So i would like to add coulmn "DELTA" to the matrix, but i am sturggeling to refere to period's "underlying value" if you know what i mean...

 

Could you help please? Thanks!

1 ACCEPTED SOLUTION
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @frmtaat ,

Actually, we cannot get your desired martix visual in power bi directly.

However, there is a workaround that we could do that. Please follow the steps below.

1. You could make a little change for the formula provided by Mariusz .

 

Diff = 
VAR tbl = ALLEXCEPT(YourTable, YourTable[GL])
VAR currentPeriod = YourTable[Period]
VAR previousPeriod = CALCULATE(
    MAX(YourTable[Period]),
    tbl,
    YourTable[Period] < CurrentPeriod
) 
VAR previousAmount = CALCULATE(
    MAX(YourTable[Amount]),
    tbl,
    YourTable[Period] = previousPeriod
)
RETURN
IF('YourTable'[Period]=1,BLANK(),YourTable[Amount] - previousAmount)

2. Create the matrix :

 

Column: Period; Raw: GL; Value: Amount and Diff. Now it looks like this:

matrix.PNG

3. You could use mouse to hide the column Diff ,Total Amount and turn off the Word warp under formatting, then your will get your desired output like below.

Untitled.png

In addition, you could refer to my attachment.

Best  Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @frmtaat ,

Actually, we cannot get your desired martix visual in power bi directly.

However, there is a workaround that we could do that. Please follow the steps below.

1. You could make a little change for the formula provided by Mariusz .

 

Diff = 
VAR tbl = ALLEXCEPT(YourTable, YourTable[GL])
VAR currentPeriod = YourTable[Period]
VAR previousPeriod = CALCULATE(
    MAX(YourTable[Period]),
    tbl,
    YourTable[Period] < CurrentPeriod
) 
VAR previousAmount = CALCULATE(
    MAX(YourTable[Amount]),
    tbl,
    YourTable[Period] = previousPeriod
)
RETURN
IF('YourTable'[Period]=1,BLANK(),YourTable[Amount] - previousAmount)

2. Create the matrix :

 

Column: Period; Raw: GL; Value: Amount and Diff. Now it looks like this:

matrix.PNG

3. You could use mouse to hide the column Diff ,Total Amount and turn off the Word warp under formatting, then your will get your desired output like below.

Untitled.png

In addition, you could refer to my attachment.

Best  Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

First of all thanks so much for both of your answers and sorry to come back so late, i have a lot going on right now and have little time to deal with PBI...

 

What i still don't get is when we declear the variable "previousAmount" and assing the value with the CALCULATE function why we need the MAX function also? As we are trying to grab the amount here, we do not need MAX right?


Thanks,

 

Mate

Mariusz
Community Champion
Community Champion

Hi @frmtaat 

 

You can add a column like below to your table.

Column = 
VAR tbl = ALLEXCEPT(YourTable, YourTable[GL])
VAR currentPeriod = YourTable[Period]
VAR previousPeriod = CALCULATE(
    MAX(YourTable[Period]),
    tbl,
    YourTable[Period] < CurrentPeriod
) 
VAR previousAmount = CALCULATE(
    MAX(YourTable[Amount]),
    tbl,
    YourTable[Period] = previousPeriod
)
RETURN
YourTable[Amount] - previousAmount

It wold be good idea to add a year to your Period column like 201901, so when it restarts from 1 the 12 can still be picked as previous 

 

Regards,
Mariusz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.