Forum Discussion

mathcathy's avatar
mathcathy
New Member
10 years ago
Solved

calculating from two date fields in one table

Hi,   I have a dataset which measures the start and end dates of many different activities. To simplify, let's say three columns - Activity Type, Start Date, Completion Date   I want to create a...
  • kdejonge's avatar
    10 years ago

    You can create a calculated table to solve this.

     

    The expression would be something like this:

    Table = var tablevalstart = SUMMARIZECOLUMNS(Table1[Start date],Table1[Activity type],"count", COUNTROWS(Table1))
    var tablevalend = SUMMARIZECOLUMNS(Table1[End date],Table1[Activity type],"count", COUNTROWS(Table1))
    var fulltable = UNION(tablevalstart,tablevalend)
    return fulltable

     

    This would first count all the occurences by start dates and activity type, then will do the same for End date and in the end Union them together. Now when you put this in a table or visual you will the sum of both each day by activity type.  

     

    You can also do this using PowerQuery but for me DAX is faster :). Hope this is what you are looking for.