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
smatesic
Helper I
Helper I

Calculate price per month and show it on line chart visual

Hello,

 

I have PBI report with sample data. The report is really simple - it has two tables and calculated DimTable. In one table I have columns shown on the picture belove:

Untitled picture.png

 

In another table I have name of the buyer, which Package/Tarifa he's buying and when his Package is expiring - DueDate column. DueDate is connected to Date in DimTable. 

Untitled picture.png

 

Question is - can I show in Line chart or in Column chart visuals PricePerMonth values by Month or YearMonth for every month?

So that column bar writes $8,33 for January, February and so on. Now it looks like this:

Untitled picture.png

 

Is there a way to make thate calculated column which will calculate PricePerMonth for every month?

 

Thanks

 

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

Hi @smatesic,

Firstly, create a new column named “Start Date” in your second table using the following formula:

Start Date = DATE(YEAR(Table2[DueDate]),MONTH(Table2[DueDate])-RELATED(Table1[DurationMonths]),DAY(Table2[DueDate]))


Secondly, create a new table by joining your second table and DimTable with the following formula:

Table = FILTER(CROSSJOIN(Table2,VALUES(DateDimension[Date])),DateDimension[Date]>=Table2[Start Date]&&DateDimension[Date]<=Table2[DueDate])


Thirdly, drag the date column of the newly created table to Axis of column chart, which looks like below, the visual calculates PricePerMonth for every month. For more details, please review the example in this attached PBIX file.
1.PNG

In addition, from my point of view, it makes sense when you create relationship between the newly created table and the second table, then drag the date coulmn to Axis of column chart. The visual will display as follows.
1.PNG


Thanks,

Lydia Zhang

Community Support Team _ Lydia Zhang
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

2 REPLIES 2
v-yuezhe-msft
Employee
Employee

Hi @smatesic,

Firstly, create a new column named “Start Date” in your second table using the following formula:

Start Date = DATE(YEAR(Table2[DueDate]),MONTH(Table2[DueDate])-RELATED(Table1[DurationMonths]),DAY(Table2[DueDate]))


Secondly, create a new table by joining your second table and DimTable with the following formula:

Table = FILTER(CROSSJOIN(Table2,VALUES(DateDimension[Date])),DateDimension[Date]>=Table2[Start Date]&&DateDimension[Date]<=Table2[DueDate])


Thirdly, drag the date column of the newly created table to Axis of column chart, which looks like below, the visual calculates PricePerMonth for every month. For more details, please review the example in this attached PBIX file.
1.PNG

In addition, from my point of view, it makes sense when you create relationship between the newly created table and the second table, then drag the date coulmn to Axis of column chart. The visual will display as follows.
1.PNG


Thanks,

Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you, this model works. I needed to see what would price look like in next 2 year period so I adapted formula and now it looks like this

Forcasting = FILTER(CROSSJOIN(Klijenti; VALUES(DimTable[Date])); DimTable[Date] >= Klijenti[Start Date] && DimTable[Date] <= Klijenti[DateIn2Years])

 

Thank you for your help

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.