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
NickzNickz
Helper IV
Helper IV

Get value from recent quarter based on date and month column.

Hi ... 

 

I have below table (sample data).

 

DateYearMonthPurchaseLoanRental
31/3/2020202036,154.571,005.50867.71
30/6/2020202061,144.23520.21630.16
30/9/202020209211.0634.68328.65
31/12/2020202012520.21540.28848.30
31/12/20202020131,144.23520.21630.16
31/3/202120213937.13551.11322.45
30/6/2021202161,093.46211.0678.53
30/9/202120219621.56118.47231.10
31/12/202120211246.20937.131,337.47
31/12/2021202113937.13551.11322.45
31/3/202220223497.50222.1246.20
30/6/20222022611,947.514.17322.45
30/9/2022202291,434.00893.86621.56
31/12/2022202212879.004,620.00497.50
31/3/202320233937.13540.28322.45
30/6/202320236211.06937.13848.30

 

For month december, I will have two record. Month 12 is a first record and Month 13 is a final record. If month 13 not exist, dax should pickup data from month 12.

 

From above statement, how can I creata a view/working table from above master data  as sample below.

 

View/Working  Table #1:

DateDescriptionAmount
31/3/2020Purchase6,154.57
31/3/2020Loan1,005.50
31/3/2020Rental867.71
30/6/2020Purchase1,144.23
30/6/2020Loan520.21
30/6/2020Rental630.16
30/9/2020Purchase211.06
30/9/2020Loan34.68
30/9/2020Rental328.65
31/12/2020Purchase1,144.23
31/12/2020Loan520.21
31/12/2020Rental630.16

 

View/Working Table #2:

DatePurchaseLoanRental
31/3/20206,154.571,005.50867.71
30/6/20201,144.23520.21630.16
30/9/2020211.0634.68328.65
31/12/20201,144.23520.21630.16

 

After that, I want to create a measure to display data in my report. Example, if current date is 31/08/2020, the result should display quarter 2 value based on category.

 

I hope my explanation is clear... 🙂 

 

Regards,

NickzNickz

 

 

 

5 REPLIES 5
technolog
Super User
Super User

I hope this message finds you well. I've noticed that this solution remain unresolved. If any of you have managed to find a resolution to the issue, I kindly request that you share your solution for the benefit of the entire community. Alternatively, if you're still facing challenges, please do let us know as well.

Your insights and updates will greatly assist others who might be encountering the same challenge.

ThxAlot
Super User
Super User

13mth.pbix

 

Aren't those two vizs the same? Anyway, easy enough

ThxAlot_0-1693378412471.png

 



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



Hi @ThxAlot ,

 

The scenario is like this, every quarter we will recieved quarter record with cumulative amount. Record for 31/12/2020 will have month 13 after the amount has been finalized. Usualy the amount/record will only available somewhere mids of next year. i.e 31/07/2021. It will supersede the original amount.

 

When we slicer by date, the record should display amount from month 13 if available. If not, use amount from month 12. My chart also will relfect. For info, my chart will have recent 3 years record (completion of the quarter cyle for that year)

 

Please find table below as reference.

 

NickzNickz_2-1693405203840.png

 

Currently I only have the TableMaster format (please refer to my original table format). I wish to have/create the above table as a view/working table instead of measure.  I will use the view/working table to create/design my reports. 

 

I hope this can clear my request... 😁

 

Your sample pbix file was great...  I really appreciate your effort. 

 

Regards,

NickzNickz

 

Mahesh0016
Super User
Super User

@NickzNickz  I hope this helps you. Thank You

> I'll guide you through the steps to achieve the two working tables and the measure you mentioned.

**Step 1: Create Working Table #1 (View/Working Table #1):**

This table displays the data in a row format for each combination of Date, Description, and Amount. You want to display the data for each month's first record (Month 12) and second record (Month 13).


ViewTable1 =
VAR FirstRecordOfMonth12 = FILTER('YourTable', 'YourTable'[Month] = 12)
VAR FirstRecordOfMonth13 = FILTER('YourTable', 'YourTable'[Month] = 13)
VAR CombinedRecords = UNION(FirstRecordOfMonth12, FirstRecordOfMonth13)
RETURN
SELECTCOLUMNS(
CombinedRecords,
"Date", 'YourTable'[Date],
"Description", "Purchase", "Amount", 'YourTable'[Purchase]
)
UNION
SELECTCOLUMNS(
CombinedRecords,
"Date", 'YourTable'[Date],
"Description", "Loan", "Amount", 'YourTable'[Loan]
)
UNION
SELECTCOLUMNS(
CombinedRecords,
"Date", 'YourTable'[Date],
"Description", "Rental", "Amount", 'YourTable'[Rental]
)

**Step 2: Create Working Table #2 (View/Working Table #2):**

This table displays the data in a column format for each category (Purchase, Loan, Rental) and Date.


ViewTable2 =
VAR FirstRecordOfMonth12 = FILTER('YourTable', 'YourTable'[Month] = 12)
VAR FirstRecordOfMonth13 = FILTER('YourTable', 'YourTable'[Month] = 13)
VAR CombinedRecords = UNION(FirstRecordOfMonth12, FirstRecordOfMonth13)
RETURN
SUMMARIZE(
CombinedRecords,
'YourTable'[Date],
"Purchase", SUM('YourTable'[Purchase]),
"Loan", SUM('YourTable'[Loan]),
"Rental", SUM('YourTable'[Rental])
)

**Step 3: Create the Measure for Quarterly Data:**

To create a measure that displays data for a specific quarter based on the current date, you can use the following DAX code:


QuarterlyValue =
VAR CurrentQuarter = INT((MONTH(NOW()) - 1) / 3) + 1
RETURN
SWITCH(
CurrentQuarter,
1, SUM('YourTable'[Purchase]), // Q1
2, SUM('YourTable'[Loan]), // Q2
3, SUM('YourTable'[Rental]), // Q3
4, BLANK() // Q4 (if needed)
)

Replace `'YourTable'` with the actual name of your table in your data model.

 

Hi @Mahesh0016 ,

I have successfully created the View/Working Table 2 as mentioned above after viewing some of videos on the YouTube... 😅 ... But the result should not combine both. Only select the latest month/value for Quarter 4. If month 13 exists, select month 13 else month 12. Quarters 1 - 3 only have 1 amount/value.

NickzNickz_0-1693534572933.png

However, I am still stuck with some errors in the formula for View/Working Table 1 as below:

 

NickzNickz_1-1693534898449.png

NickzNickz_2-1693535211097.png

 

Hope @Mahesh0016  or anyone can assist me on this matter...

 

Thank you.

Regards,

NickzNickz

 

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors