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
aar0n
Advocate II
Advocate II

How to make a calculated 'days' column

Hours OnlineDateLocationDays OnlineProduction
01/1/2017A00
01/2/2017A00
121/3/2017A15
241/4/2017A210
241/5/2017A35
241/6/2017A420
01/8/2017B00
01/9/2017B00
01/10/2017B00
241/11/2017B15
241/12/2017B25
51/13/2017B25
101/14/2017B210
241/15/2017B320

The first 3 columns is what i have, and the 4th column is what i would like to calculate. 

 

Basically, i want to convert the 'hours online' values into a 'days online'.  im trying to get a calculation that will sum all the hours, and only add 1 day to the to the 'days online' value if the sum is 24. 

 

I am trying to plot 'Days online' on the x axis, and 'Production' on the Y-axis - for both locations, so that i can compare how each location performs relative to each other.

4 ACCEPTED SOLUTIONS

HI @aar0n

 

Try this Calculated Column

 

Column =
VAR myDaysOnline =
    CALCULATE (
        COUNTROWS ( TableName ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[Location] ),
            TableName[Hours Online] = 24
                && TableName[Date] <= EARLIER ( TableName[Date] )
        )
    )
RETURN
    IF ( ISBLANK ( myDaysOnline ), 0, myDaysOnline )

Regards
Zubair

Please try my custom visuals

View solution in original post

HI @aar0n

 

In that case use this Column

 

Column =
VAR CumulativeHours =
    CALCULATE (
        SUM ( TableName[Hours Online] ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[Location] ),
            TableName[Date] <= EARLIER ( TableName[Date] )
        )
    )
RETURN
    ROUNDDOWN ( DIVIDE ( CumulativeHours, 24 ), 0 )

Regards
Zubair

Please try my custom visuals

View solution in original post

HI @aar0n

 

Please could you try this

 

Just Replaced ROUNDDown with QUOTIENT

 

Column =
VAR CumulativeHours =
    CALCULATE (
        SUM ( TableName[Hours Online] ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[Location] ),
            TableName[Date] <= EARLIER ( TableName[Date] )
        )
    )
RETURN
    QUOTIENT ( CumulativeHours, 24 )

Regards
Zubair

Please try my custom visuals

View solution in original post

10 REPLIES 10

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.