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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Difference by column values

Hello All, 

 

I have sitiation where i have to caliculate the diffrence 

CategorySubstationProject phasePlanned Cost
Grid AutomationArdmorePLAN515972.7981
Grid ResiliencyArdmorePLAN1137192.94
Grid AutomationBellcowMODEL1114147.5
Grid AutomationBellcowPLAN1174533.554
Grid ResiliencyBellcowMODEL2500330
Grid ResiliencyBellcowPLAN2157894.014
Grid AutomationBelle Isle StaMODEL1657040
Grid AutomationBelle Isle StaPLAN1550595.136
Grid ResiliencyBelle Isle StaMODEL1538123.351
Grid ResiliencyBelle Isle StaPLAN1631975.692

 

now I have to caluclate the diffrence between plan and model for each Category and Substation

Example 

for Category : Grid Automation = (sum of cost of plan ) - (sum of cost of model )

and also for Subsation: Bellcow = (sum of cost of plan ) - (sum of cost of model )

but now the Subsation Ardmore has no  MODEL so the difference will be just sum of cost of plan 

 

Thanks

RP

1 ACCEPTED SOLUTION
v-yuaj-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, you can do some steps as follows。

  1. Create a calculated index column.

 

index =

RANKX (

    FILTER (

        CASE,

        EARLIER ( CASE3[Category] ) = CASE[Category]&&EARLIER('CASE'[Substation])='CASE'[Substation]

    ),

    'CASE'[Project phase],

    ,

    DESC

)

v-yuaj-msft_0-1604626591213.png

 

  1. Create a measure.

 

Measure =

var x1 = CALCULATE(MAX('CASE'[Planned Cost]),FILTER(ALLEXCEPT('CASE',CASE[Category],CASE[Substation]),[index]=1))

var x2 = CALCULATE(MAX('CASE'[Planned Cost]),FILTER(ALLEXCEPT('CASE',CASE[Category],CASE[Substation]),[index]=2))

return

x1-x2

 

Result:

v-yuaj-msft_1-1604626591220.png

 

Hope that's what you were looking for.

 

Best Regards,

Yuna

 

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

2 REPLIES 2
v-yuaj-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, you can do some steps as follows。

  1. Create a calculated index column.

 

index =

RANKX (

    FILTER (

        CASE,

        EARLIER ( CASE3[Category] ) = CASE[Category]&&EARLIER('CASE'[Substation])='CASE'[Substation]

    ),

    'CASE'[Project phase],

    ,

    DESC

)

v-yuaj-msft_0-1604626591213.png

 

  1. Create a measure.

 

Measure =

var x1 = CALCULATE(MAX('CASE'[Planned Cost]),FILTER(ALLEXCEPT('CASE',CASE[Category],CASE[Substation]),[index]=1))

var x2 = CALCULATE(MAX('CASE'[Planned Cost]),FILTER(ALLEXCEPT('CASE',CASE[Category],CASE[Substation]),[index]=2))

return

x1-x2

 

Result:

v-yuaj-msft_1-1604626591220.png

 

Hope that's what you were looking for.

 

Best Regards,

Yuna

 

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

amitchandak
Super User
Super User

@Anonymous , Try measure like

sumx(filter(Table[Project phase] = "PLAN"),Table[Planned Cost]) -sumx(filter(Table[Project phase] = "MODEL"),Table[Planned Cost])

or
sumx(Table, if( Table[Project phase] = "PLAN" , Table[Planned Cost] , -1 *Table[Planned Cost]))

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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