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
rahul632soni
Helper I
Helper I

how to get sum with specific data

rahul632soni_0-1679031529128.png

 

I have this data available , now i want to calculate Header Hours which is Difference of Max and Min Engine HOurs , However it is working with Same level of Grouping as we have Engine Hours Details on Vin Level , hence when i select only header A i want to get total Header Hours as around 211 Hours , however when i am doing it on Header Level i am getting total Header Hours as 1134 Hours as shown below 

 

rahul632soni_1-1679031726474.png

How can i achieve this .

Let me know for any other question related to data .

Regards

Rahul 

 

5 REPLIES 5
rahul632soni
Helper I
Helper I

@lbendlin 

Super Thanks its working actually , 

however just one more input, Instead of creating a table with the provided data , because that was just sample data

in below image it can be seen that we have a table which have all these variable , so can we use directly from here and create new table so that it would be dynamic.

rahul632soni_0-1679575748906.png

in image we can see the table name and all other variable which i showed as sample data.

 

Thanks in Advance 🙂

Regards

Rahul

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

@lbendlin 

Hey Below is the  table with data which is availabe

Header_NamevinInstance-FlagENG_HOURS
AHAJSR22HKMG6799221202.1
AHAJSR22HKMG6799221202.2
AHAJSR22HKMG6799221202.3
AHAJSR22HKMG6799221202.4
AHAJSR22HKMG6799221208.7
AHAJSR22HKMG6799221208.8
AHAJSR22HKMG6799221208.9
AHAJSR22HKMG6799221209
AHAJW210HKMG67992411153.9
AHAJW210HKMG67992411154
AHAJW210HKMG67992411154.1
AHAJW210HKMG67992411154.2
AHAJW210HKMG67992411154.3
AHAJW210HKMG67992411234.2
AHAJW210HKMG67992411234.3
AHAJW210HKMG67992411234.4
AHAJW210HKMG67992411234.5
AHAJW210HKMG6799242100
AHAJW210HKMG6799242100.1
AHAJW210HKMG6799242100.2
AHAJW210HKMG6799242100.3
AHAJW210HKMG6799242100.4
AHAJW210HKMG6799242199.7
AHAJW210HKMG6799242199.8
AHAJW210HKMG6799242199.9
AHAJW210HKMG6799242200
BHAJSR22HKMG6799221241
BHAJSR22HKMG6799221241.1
BHAJSR22HKMG6799221241.2
BHAJSR22HKMG6799221241.9
BHAJSR22HKMG6799221242
BHAJSR22HKMG6799221242.1
BHAJSR22HKMG6799221259.4
BHAJSR22HKMG6799221259.5
BHAJSR22HKMG6799221259.6
BHAJSR22HKMG6799221259.7
BHAJSR22HKMG6799221259.8
BHAJSR22HKMG6799221259.9
BHAJSR22HKMG6799221260
BHAJSR26HLMG6799061739.4
BHAJSR26HLMG6799061739.5
BHAJSR26HLMG6799061739.6
BHAJSR26HLMG6799061739.7
BHAJSR26HLMG6799061739.8
BHAJSR26HLMG6799061739.9
BHAJSR26HLMG6799061766.5
BHAJSR26HLMG6799061766.6
BHAJSR26HLMG6799061766.7

This Talks about that a Particular Header was attached to a VIn during which Engine Hours .

we need Total Engine Hours for Each Header , Engine Hours can be calculated using Difference of Max Engine Hours  and Min Engine Hours For Each VIn and Each Instance for Each Header .

Below is the Output Required 

Header_NameHeader Hours
A187.5
B46.3

Regrads

Rahul

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jdK7DsMgDAXQf2GOEJinx3Rp1MfSDh2i/P9vlLwqhRK4Aws6suxrj6PoRSeG/vZ+EQ3359UHZqL0p9MjRVKLqWsrgpSBlAVUlAFSEVIMqIP5kFY/YzejtTMSYhZCx+jPGWHMtBkZqNrMwGrApDNzVbYsQSnENDLbVX3IXdVn3FV9xEUxH8/1VEVI1W+MlnNd07rUTtpqxEhMEaQYUEglQrpyvO2mpRykPKQCpCKkgLR8vmc/PFaj/GaC+c+hrPIcyirPoazyHMoqz6Gs8hwKynuk+6SA7pNK3U9f", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Header_Name = _t, vin = _t, #"Instance-Flag" = _t, ENG_HOURS = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ENG_HOURS", type number}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Header_Name","vin","Instance-Flag"}, {{"Min Hours", each List.Min([ENG_HOURS]), type number}, {"Max Hours", each List.Max([ENG_HOURS]), type number}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Header Hours", each [Max Hours]-[Min Hours]),
    #"Grouped Rows1" = Table.Group(#"Added Custom", {"Header_Name"}, {{"Header Hours", each List.Sum([Header Hours]), type number}})
in
    #"Grouped Rows1"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

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.