Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Generate a date range to make a line between 2 dates

Hello,    I have a request in Power BI   I have a table like this :    Date start Date end     Quantity  1/12          31/12             17   I want this information with anothers informatio...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

    Have you solved your problem?
    If not, please try this way:
    Use the DAX below to create a new table:

    Date table = CALENDAR(MAX('Table'[Date start]), MAX('Table'[Date end]))

    Then use the DAXs below to achieve your expected results:

    Value = 
    VAR A = SELECTEDVALUE('Table'[Quantity])
    VAR B = CALCULATE(COUNTROWS('Date table'),ALLSELECTED('Date table')) - 1
    RETURN
    IF(
        'Date table'[Date].[Day] = 1,
        0,
        DIVIDE(A, B)
    )
    Value2 = 
    VAR A = SELECTEDVALUE('Table'[Quantity])
    VAR B = CALCULATE(COUNTROWS('Date table'),ALLSELECTED('Date table')) - 1
    VAR C =
    IF(
        'Date table'[Date].[Day] = 1,
        0,
        DIVIDE(A, B)
    )
    VAR D = 'Date table'[Date].[Day] - 1
    RETURN
    C * D

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