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.
I have a main table dataset (Table 2 below) that is imported in to PowerBI Desktop that contains a list of customers, agreements, the current monthly price and date range of how long that agreement goes.
I want to be able to create a dynamic visualization based on this data that shows in grid or matrix format the information like the Table 1 Below. This visualization would show the current and next 12 months total active agreements.
I do have a Date table with a relationship to Table2. The Date table contains a row for each day
Seeking help on how to use the data in Table 2 to achieve a visual like Table 1. Thoughts?
Desired Visualization (Table 1):
Table 2:
I do have a Date Table as well that contains each day:
Date | Year | Year Month Name |
1/25/2021 | 2021 | January 2021 |
1/26/2021 | 2021 | January 2021 |
2/1/2021 | 2021 | February 2021 |
x | x | x |
x | x | x |
Solved! Go to Solution.
Hi @mick22 ,
Here are the steps you can follow:
1. Create calculated table2.
Table2:
Table 2 =
CALENDAR(MIN('Table'[StartDate]),MAX('Table'[EndDate]))
Create the calculated column in Table2:
Year1 =
VALUE( FORMAT('Table 2'[Date],"yyyymm"))
Year2 =
VALUE( FORMAT('Table 2'[Date],"yyyymm"))
2. Create calculated table3.
Table3:
Table 3 =
DISTINCT('Table 2'[Year2])
3. Create measure.
Flag =
var _1=CALCULATE(SUM('Table'[CurrentMonthlyPrice]),FILTER(ALL('Table 2'),'Table 2'[Year1]>=VALUE( FORMAT(MAX('Table'[StartDate]),"yyyymm"))&&MAX('Table 3'[Year2])<=VALUE( FORMAT(MAX('Table'[EndDate]),"yyyymm"))))
return
IF(
MAX('Table 3'[Year2])<=MAX('Table 2'[Year1]),_1
,0)
Total_Incorrect =
var _table=SUMMARIZE('Table 2','Table 2'[Year1],"_value",[Flag])
return
IF(HASONEVALUE('Table 2'[Year1]),[Flag],SUMX(_table,[_value]))
4. Result:
Refer to:
https://community.powerbi.com/t5/Desktop/Create-Lower-Triangular-Matrix/m-p/854339
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @mick22 ,
Here are the steps you can follow:
1. Create calculated table2.
Table2:
Table 2 =
CALENDAR(MIN('Table'[StartDate]),MAX('Table'[EndDate]))
Create the calculated column in Table2:
Year1 =
VALUE( FORMAT('Table 2'[Date],"yyyymm"))
Year2 =
VALUE( FORMAT('Table 2'[Date],"yyyymm"))
2. Create calculated table3.
Table3:
Table 3 =
DISTINCT('Table 2'[Year2])
3. Create measure.
Flag =
var _1=CALCULATE(SUM('Table'[CurrentMonthlyPrice]),FILTER(ALL('Table 2'),'Table 2'[Year1]>=VALUE( FORMAT(MAX('Table'[StartDate]),"yyyymm"))&&MAX('Table 3'[Year2])<=VALUE( FORMAT(MAX('Table'[EndDate]),"yyyymm"))))
return
IF(
MAX('Table 3'[Year2])<=MAX('Table 2'[Year1]),_1
,0)
Total_Incorrect =
var _table=SUMMARIZE('Table 2','Table 2'[Year1],"_value",[Flag])
return
IF(HASONEVALUE('Table 2'[Year1]),[Flag],SUMX(_table,[_value]))
4. Result:
Refer to:
https://community.powerbi.com/t5/Desktop/Create-Lower-Triangular-Matrix/m-p/854339
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Liu Yang - So I got this working a bit better and it pretty much looks like your example output. The only problem I'm having is that it's adding up CurrentMonthlyPrice for months that it should not based on YEAR1/YEAR2 being outside of the range of StartDate and EndDate. I did update my example in original post to clarify and post correct calculations. Any idea on why this might be happening?
Hi,
I cannnot understand your result. First of all i think the year in the price start date column of Agree2 should be 2022 (not 2021). Please confirm that. Furthermore, how do you interpret the figure 250 at the intersection of June 2022 (row 2) and May 2022 (column1). I have done something based on my understanding. Download the PBI file from here.
Hope this helps.
Ashish - I like your output but the difference is your table called Data should have an Start Date and End Date. Values should be calculated for the Month (and projected out) IF they are between those Start and End Dates and displayed like you are doing.
I have updated my figures for my desired visualization to make things more clear.
My Data table has a start and an end date. I have carried out some transformations on that table to get a single column dates. Please study the steps in the Query Editor.
I made some progress and things look good in Power Query Editor after reviewing your steps! Thank you. I do have a question though... I'm not getting month names across the top.
You are welcome. In the Column labels, you should drag Year and Month name from the Calendar_dup table.
If my previous reply helped, please mark that reply as Answer.
I did that previously but they still didn't come through.
I cannot help unless i see your file.
Ashish - I apologize, I'll look closer! I truly appreciate your time in trying to help me out.
@mick22 , You have to join it with two date tables. You have filter one of the table for 12 month
refer
Cohort Analysis: https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-3-Period-Of-Stay-Cohort-Anal...
In case you want to select one date and want filter more than that
Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
104 | |
77 | |
67 | |
63 |
User | Count |
---|---|
144 | |
107 | |
105 | |
82 | |
69 |