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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
itsranga
Helper I
Helper I

Need Help - DAX Code

Hi Team,  I have a Data like this (Top table), I need result like bottom table

itsranga_0-1753781911650.png

 

  • If the Parent Ticket is not blank, the Relevant hrs should be blank.
  • If the Parent Ticket is blank, the result should be the sum of hours for all rows that the same Parent Ticket.

    how to achieve this using DAX
1 ACCEPTED SOLUTION

This is very simple but in your original data it was not like this, here is the table you showed

 

FBergamaschi_0-1753872773016.png

 

Anyway I adjusted the data and now I have the following

 

FBergamaschi_1-1753872930724.png

 

and now I have what you want without any hardwiring:

 

Test =
VAR Ticket = Tabella[Ticket No]
RETURN
SUMX ( FILTER ( Tabella, Tabella[Parent Ticket] = Ticket ), Tabella[Total Hrs] )
 
The above is a column
 
If you want a measure, let me know
 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

View solution in original post

17 REPLIES 17
v-tejrama
Community Support
Community Support

Hi @itsranga ,

 

Thanks for sharing the detailed process you’ve explained it quite well, and your approach is absolutely correct. Just to confirm, once you load your data into Power BI from Excel or your relevant source, you can go ahead and create the "Relevant Hrs" calculated column in the Data view.
The DAX expression you've mentioned works fine  it checks if the Parent Ticket is not blank and then uses CALCULATE with ALLEXCEPT to sum the Total Hrs grouped by Parent Ticket. If the Parent Ticket is blank, it rightly returns a blank value. After that, adding the fields like Ticket No, Summary, Parent Ticket, Total Hrs, and the newly created Relevant Hrs into a Table visual in Report view is the right way to go.
Based on your example, if multiple rows share the same Parent Ticket, the Relevant Hrs should show the correct total, like 586 for the Data Conversion case, while entries without a Parent Ticket (like Hourly Conversion) will show blank, which is expected. You can also apply conditional formatting or adjust the column widths to improve readability. Once everything looks good, saving the report and publishing it to the Power BI Service is the final step.
Please feel free to text me back if you have any questions
I’ve attached the .pbix file and screen shorts used in this test for your reference.

vtejrama_0-1753865417974.png

 



Thank you.
Tejaswi.

 

@v-tejrama  thanks for your suppot,   somewhat okay  i slightly changed the formula it's okay but 


This is a parent-child ticket concept. For example, one parent ticket can have multiple child tickets. I need to display  in a new column, show the sum of all the child ticket hours.
In this case, ticket number 1043930 is the parent ticket (row 1), and rows 3 and 4 are its child tickets. So, I need to calculate the sum of hours where the ticket number matches the parent ticket, and display that sum in the parent ticket's row

itsranga_1-1753872346047.png

 

 

Hi @itsranga ,

 

Thank you @FBergamaschi  for the helpful input!

Were you able to resolve the issue? If the response addressed your query, kindly confirm. This helps keep the community informed and improves solution visibility.

Thank you for your support!

This is very simple but in your original data it was not like this, here is the table you showed

 

FBergamaschi_0-1753872773016.png

 

Anyway I adjusted the data and now I have the following

 

FBergamaschi_1-1753872930724.png

 

and now I have what you want without any hardwiring:

 

Test =
VAR Ticket = Tabella[Ticket No]
RETURN
SUMX ( FILTER ( Tabella, Tabella[Parent Ticket] = Ticket ), Tabella[Total Hrs] )
 
The above is a column
 
If you want a measure, let me know
 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

techies
Super User
Super User

Hi @itsranga please try this measure

 

Relevant Hrs Measure =
VAR ThisTicket = SELECTEDVALUE('Sheet6'[Ticket No])
VAR IsParent = ISBLANK(SELECTEDVALUE('Sheet6'[Parent Ticket]))
RETURN
IF (
    IsParent,
    CALCULATE (
        SUM ( 'Sheet6'[Total Hrs] ),
        FILTER (
            ALL('sheet6'),
            'Sheet6'[Parent Ticket] = ThisTicket
                || 'Sheet6'[Ticket No] = ThisTicket
        )
    )
)
 
techies_0-1753857379447.png

 

― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

@techies  thanks for your response,  I need result like this
its return wrong value

itsranga_0-1753861102587.png

 

ok, please try this 

 

Relevant Child Hrs Measure =
VAR ThisTicket = SELECTEDVALUE('Sheet6'[Ticket No])
RETURN
CALCULATE (
    SUM ( 'Sheet6'[Total Hrs] ),
    FILTER (
        ALL('Sheet6'),
        'Sheet6'[Parent Ticket] = ThisTicket
    )
)
― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

@techies   No its return wrong value,  some other bigger value it's retun
attached screenshot for your refrence, 

itsranga_1-1753862943650.png

 

itsranga
Helper I
Helper I

@FBergamaschi 

Ticket NoSummary Parent TicketTotal Hrs  
1049039Data Conversion 678.5  
1323146Table Conversion10493039346  
1456862Table Conversion_110493039240  
1140978Hourly Conversion 186.5  
      
      
I need result like this    
      
Ticket NoSummary Parent TicketTotal HrsRelevant hrsTotal Hrs
1049039Data Conversion 678.55861264.5
1323146Table Conversion10493039346  
1456862Table Conversion_110493039240  
1140978Hourly Conversion 186.5  

 

 

many different parent ticket is not possible, one parent ticket only for one ticket

FBergamaschi_0-1753787109361.png

 

calculated column code

 

Colonna =
IF ( ISBLANK( Tabella[Parent Ticket] ) && Tabella[Summary ] <> "Hourly Conversion", SUMX ( FILTER ( Tabella, NOT ISBLANK( Tabella[Parent Ticket] ) ), Tabella[Total Hrs] ) )
 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

@FBergamaschi 

Colonna =
IF ( ISBLANKTabella[Parent Ticket] ) && Tabella[Summary ] <> "Hourly Conversion"SUMX ( FILTER ( TabellaNOT ISBLANKTabella[Parent Ticket] ) ), Tabella[Total Hrs] ) )


This IF condition is hardcoded for 'Hourly conversion'. I tried to avoid this code and used a DAX expression instead, but it caused a circular dependency error. Please correct the error

That was the only way to avoid getting the 586 total also in the last row which also has blank Parent Ticket

 

I do not find your code, though, where is it? In your message I only see my code

Measure =
VAR CurrentID = SELECTEDVALUE ( Table[Ticketno] )
RETURN
CALCULATE (
    SUM ( Table[Hours] ),
    Table[Parent Ticket] = CurrentID
)

@FBergamaschi i tried using this measure

This code cannot work as a measure

 

Measure =
VAR CurrentID = SELECTEDVALUE ( Tabella[Ticket no] )
RETURN
CALCULATE (
    SUM ( Tabella[Total Hrs] ),
    Tabella[Parent Ticket] = CurrentID
)
 
My code was for a column. The point is that the last row has an empty Parent Ticket like the first one so how do we make the difference? I wrote 
 
Colonna =
IF ( ISBLANKTabella[Parent Ticket] ) && Tabella[Summary ] <> "Hourly Conversion"SUMX ( FILTER ( TabellaNOT ISBLANKTabella[Parent Ticket] ) ), Tabella[Total Hrs] ) )
 
but if you prefer you can use 
 
Colonna =
IF ( ISBLANKTabella[Parent Ticket] ) && Tabella[Summary ] = "Data Conversion"SUMX ( FILTER ( TabellaNOT ISBLANKTabella[Parent Ticket] ) ), Tabella[Total Hrs] ) )
 
and it will work as you were asking? We can avoid the hardwire if you specify another way to identify the last row vs the first one
 
But now I ask you: do you need a column or a measure? To me, you need a column but of course please let me know otherwise
 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

FBergamaschi
Solution Sage
Solution Sage

In your picture, in the results table, the first row has empty Parent Ticket, though you want to see 586?

 

This is in contrast with your definition:

 

  • If the Parent Ticket is blank, the Relevant hrs should be blank.

Please clarify and resend the result you want

 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

@FBergamaschi 

  • If the Parent Ticket is blank, the result should be the sum of hours for all rows that the same Parent Ticket. (screenshot red color highlighted)
  • If the Parent Ticket is not blank, the Relevant hrs should be blank.

Ok now it is clearer, please provide the table in a usable format, not an image

 

And What if there are many different Parent Tickets? Like two differen parent tickets in 5 different lines, 3 with the first parent ticket and the other two with the other one?

 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors