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
jasgun01
Frequent Visitor

Data Modelling Help

Hi,

 

I have a table with a measure "Limit Amount Our Share GBP" that I need to create a matrix report at each month end. I have created new measures based on Feb & Jan 2019 month end, but need to go back to January 2017 and this report will be used for future months as well.

 

Rather than creating lots of measures for future & past month ends how can I do t by creating another table listing the month end dates???

 

Below is an example of the measure I've created and the matrix so far, highlighting the measure and date paramenters.

 

PBI_NBCR.png

 

 

Any assistance will be great!

 

Thanks

 

Jason

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @jasgun01,

Sorry I miss the bit where you use two different dates.

 

You can use the pattern below:

First create Table:

Year Month =
VAR CY = YEAR(TODAY())
VAR SY = CY -2
RETURN
ADDCOLUMNS(
CROSSJOIN(
SELECTCOLUMNS(GENERATESERIES(SY, CY), "Year", [Value]),
SELECTCOLUMNS(GENERATESERIES(1, 12), "Month", [Value])
),
"StartDate", DATE([Year], [Month], 1)
)
 
Add two Columns to that Table:
EndDate = EOMONTH('Year Month'[StartDate],0)
Year Month = FORMAT('Year Month'[StartDate], "YYYYMM")
Create Measure:
calc =
CALCULATE(
SUM('Your Table'[Value]),
FILTER(
'Your Table',
'Your Table'[Date] <= MAX('Year Month'[EndDate])
&& 'Your Table'[Date] >= MAX('Year Month'[StartDate])
)
)

Hope this helps 
Mariusz

View solution in original post

3 REPLIES 3
Mariusz
Community Champion
Community Champion

Hi @jasgun01,

You can use calendar table (dimension) with Year Month Column that goes to your Matrix column and just use your Measure without a need for complex dax.

Hope this helps
Mariusz


Hi @Mariusz 

 

Thanks for you assistance once more.

I have added the calendar table to my model, however I have two date field parameters that I use to calculate the measure <= "PolicyIncpetionDate" & >= "PolicyExpiryDate".

 

PBI_NBCR-2.png

 

I thought about adding the Calendar table twice and have two joins, both on the "Date" but then one to each of the date fields mentioned above.

PBI_NBCR-3.png

 

But thats where I'm stuck! How do I calculate the measure automatically for the two paramenters based on the MonthYearNum on the Calendar table????

 

Mariusz
Community Champion
Community Champion

Hi @jasgun01,

Sorry I miss the bit where you use two different dates.

 

You can use the pattern below:

First create Table:

Year Month =
VAR CY = YEAR(TODAY())
VAR SY = CY -2
RETURN
ADDCOLUMNS(
CROSSJOIN(
SELECTCOLUMNS(GENERATESERIES(SY, CY), "Year", [Value]),
SELECTCOLUMNS(GENERATESERIES(1, 12), "Month", [Value])
),
"StartDate", DATE([Year], [Month], 1)
)
 
Add two Columns to that Table:
EndDate = EOMONTH('Year Month'[StartDate],0)
Year Month = FORMAT('Year Month'[StartDate], "YYYYMM")
Create Measure:
calc =
CALCULATE(
SUM('Your Table'[Value]),
FILTER(
'Your Table',
'Your Table'[Date] <= MAX('Year Month'[EndDate])
&& 'Your Table'[Date] >= MAX('Year Month'[StartDate])
)
)

Hope this helps 
Mariusz

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.