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
Anonymous
Not applicable

DAX - Dividing value (current date) by value (first date that appears for the month)

Hello everyone,

 

I'm trying to create a measure to divide quantity value of the current date by the value of the first date that appears forthe month. 

(e.g. 31 May Item A quantity value divided by 17 May Item A quantity value)
(e.g. 24 May Item A quantity value divided by 17 May Item A quantity value)
(e.g. 17 May Item A quantity value divided by 17 May Item A quantity value)

blueraccoon_1-1624432427645.png

 

Thanks in advance!

 

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@Anonymous,

 

Try this measure:

 

Percentage = 
VAR vCurrentQty =
    SUM ( 'Item'[Quantity] )
VAR vCurrentYear =
    YEAR ( MAX ( 'Item'[Date] ) )
VAR vCurrentMonth =
    MONTH ( MAX ( 'Item'[Date] ) )
VAR vFirstDateInMonth =
    CALCULATE (
        MIN ( 'Item'[Date] ),
        ALLEXCEPT ( 'Item', 'Item'[Item] ),
        YEAR ( 'Item'[Date] ) = vCurrentYear,
        MONTH ( 'Item'[Date] ) = vCurrentMonth
    )
VAR vEarliestQtyInMonth =
    CALCULATE (
        SUM ( 'Item'[Quantity] ),
        ALLEXCEPT ( 'Item', 'Item'[Item] ),
        'Item'[Date] = vFirstDateInMonth
    )
VAR vResult =
    DIVIDE ( vCurrentQty, vEarliestQtyInMonth )
RETURN
    vResult

 

DataInsights_0-1624540562525.png

Sample data:

 

DataInsights_1-1624540577742.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
DataInsights
Super User
Super User

@Anonymous,

 

Try this measure:

 

Percentage = 
VAR vCurrentQty =
    SUM ( 'Item'[Quantity] )
VAR vCurrentYear =
    YEAR ( MAX ( 'Item'[Date] ) )
VAR vCurrentMonth =
    MONTH ( MAX ( 'Item'[Date] ) )
VAR vFirstDateInMonth =
    CALCULATE (
        MIN ( 'Item'[Date] ),
        ALLEXCEPT ( 'Item', 'Item'[Item] ),
        YEAR ( 'Item'[Date] ) = vCurrentYear,
        MONTH ( 'Item'[Date] ) = vCurrentMonth
    )
VAR vEarliestQtyInMonth =
    CALCULATE (
        SUM ( 'Item'[Quantity] ),
        ALLEXCEPT ( 'Item', 'Item'[Item] ),
        'Item'[Date] = vFirstDateInMonth
    )
VAR vResult =
    DIVIDE ( vCurrentQty, vEarliestQtyInMonth )
RETURN
    vResult

 

DataInsights_0-1624540562525.png

Sample data:

 

DataInsights_1-1624540577742.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Thank you for your help kind sir, have a good weekend 😉

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.