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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
xmarkx
Frequent Visitor

Uniform split and allocation amount into months

Hello there BI community!

I have a table which holds data on transactions for licences. The licences have a period they are valid, and a price for the whole period. I also have a date table which has Date, Year, Month, and Month-Year ("mmm-yyyy") columns among others.

The table looks as follows:
Example data tableExample data table

The desired result would take PricePerPeriod and add it to the respective Month-Year.

  • If the period is a year (PaymentMethod=3), then PricePerPeriod should be added to 12 months from the PeriodFrom month,
  • If the period is one month (PaymentMethod=2), then PricePerPeriod should be added to the respective PeriodFrom month.

 

The PricePerPeriod colum is calcuated from the Price column based on the logic bescribed above.

The desired output would look like this:
Desired outputDesired output

My closest solution looks like this, but it has unwanted results.

 

Total Value Year Month 3 = 
-- Similar code as Total Value Year Month 2, but without the DIVIDE function. The result is not really as desired
SUMX(
    VALUES('Date'[Month-Year]),
    CALCULATE(  
        SUMX(
            FILTER(
                Activations, 
                Activations[PeriodFrom] <= MAX('Date'[Date]) && Activations[PeriodTo] >=MAX('Date'[Date])
                ), 
                Activations[PricePerPeriod]
            )
        )
    )

 

I see (when I click on Name=A or Name=H in the Original input table) that it does not calculate the value 1000 there.I see (when I click on Name=F in the Original input table) that it does calculate the value 1000 for both January and February although I would expect it to only appear in January month (Note the leap day on February 29th).

I can upload a pbix file with my experiments, measures with comments, explanation of the problem, raw data and desired output if needed, but unfortunately i am not able upload it here on the forum directly.

If you have any questions or suggestions please feel free to ask.

Thank you all in advance! 🙂

 

1 ACCEPTED SOLUTION

Hi @xmarkx ,

Below is my table1:

vxiandatmsft_0-1713333700131.png

Below is my date:

vxiandatmsft_1-1713333716565.png

The following DAX might work for you:

MonthlyLicenseValues = 
ADDCOLUMNS (
    'Date',
    "PricePerMonth1",
    SUMX (
        FILTER (
            Activations,
            Activations[PeriodFrom] <= 'Date'[Date]
                && Activations[PeriodTo] >= 'Date'[Date]
        ),
        IF (
            Activations[PaymentMethod] = 3, -- Yearly payment
            Activations[PricePerPeriod], -- Divide yearly price by 12 months
            Activations[PricePerPeriod]
        )
    )
)

The final output is shown in the following figure:

vxiandatmsft_2-1713333765460.png

If that still doesn't fix it, please provide the pbix file.

Best Regards,

Xianda Tang

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

View solution in original post

3 REPLIES 3
v-xiandat-msft
Community Support
Community Support

Hi @xmarkx ,

Here’s how you can approach this:

  • Create a calculated table called
  • In the formula, use DAX to calculate the appropriate for each month based on the payment method.
  • Sum up the for each month.
MonthlyLicenseValues =
ADDCOLUMNS (
    'Date',
    "PricePerMonth",
    SUMX (
        FILTER (
            Activations,
            Activations[PeriodFrom] <= 'Date'[Date]
                && Activations[PeriodTo] >= 'Date'[Date]
        ),
        IF (
            Activations[PaymentMethod] = 3, -- Yearly payment
            Activations[PricePerPeriod] / 12, -- Divide yearly price by 12 months
            Activations[PricePerPeriod]
        )
    )
)

Best Regards,

Xianda Tang

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

 

@v-xiandat-msft 

Thank you for your suggestion.

I tried your solution but the result were way off from the expected result. See the result and desired result comparison here:
Solution result VS desired resultSolution result VS desired result

Did you try it yourself?
Do you have any idea about an improvement?
Also i was looking for a solution as a measure so i can dinamically filter it.

 

Hi @xmarkx ,

Below is my table1:

vxiandatmsft_0-1713333700131.png

Below is my date:

vxiandatmsft_1-1713333716565.png

The following DAX might work for you:

MonthlyLicenseValues = 
ADDCOLUMNS (
    'Date',
    "PricePerMonth1",
    SUMX (
        FILTER (
            Activations,
            Activations[PeriodFrom] <= 'Date'[Date]
                && Activations[PeriodTo] >= 'Date'[Date]
        ),
        IF (
            Activations[PaymentMethod] = 3, -- Yearly payment
            Activations[PricePerPeriod], -- Divide yearly price by 12 months
            Activations[PricePerPeriod]
        )
    )
)

The final output is shown in the following figure:

vxiandatmsft_2-1713333765460.png

If that still doesn't fix it, please provide the pbix file.

Best Regards,

Xianda Tang

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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