Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I am trying to create a new table in power bi model with calculate table function using related table as a filter for previous month.
Here is a working dax code just without the mentioned filter:
TEST A =
CALCULATETABLE(
SELECTCOLUMNS(
FinancingContractHeader,
"Customer Name", FinancingContractHeader[Customer Name],
"Customer No", FinancingContractHeader[Customer No_],
"Registration No", FinancingContractHeader[Registration No_],
"Licence Plate No", FinancingContractHeader[Licence Plate No],
"VIN", FinancingContractHeader[VIN],
"Contract No", FinancingContractHeader[No_],
"Status", FinancingContractHeader[Status Groups],
"Product", FinancingContractHeader[Financing Product Type Code],
"Start Date", SELECTCOLUMNS(RELATEDTABLE('Payment Calendar'),'Payment Calendar'[Start Date]),
"End Date", SELECTCOLUMNS(RELATEDTABLE('Payment Calendar'),'Payment Calendar'[End Date]),
"Service Part", SELECTCOLUMNS(RELATEDTABLE('Payment Calendar'),'Payment Calendar'[Service Part]),
"Finance Part", SELECTCOLUMNS(RELATEDTABLE('Payment Calendar'),'Payment Calendar'[Finance Part]),
"Total Lease Payment", SELECTCOLUMNS(RELATEDTABLE('Payment Calendar'),'Payment Calendar'[Total Lease Payment]),
"Year", SELECTCOLUMNS(RELATEDTABLE('Payment Calendar'),'Payment Calendar'[Year]),
"Month", SELECTCOLUMNS(RELATEDTABLE('Payment Calendar'),'Payment Calendar'[Month]),
"Date", SELECTCOLUMNS(RELATEDTABLE('Payment Calendar'),'Payment Calendar'[Date])
),
FinancingContractHeader[Financing Product Type Code] = "OL" ||
FinancingContractHeader[Financing Product Type Code] = "SLB",
FinancingContractHeader[Status Groups] = "Active" ||
FinancingContractHeader[Status Groups] = "Archived" ||
FinancingContractHeader[Status Groups] = "Closed" ||
FinancingContractHeader[Status Groups] = "Settled"
)
Now I need to add condition 'Payment Calendar'[Date] is in previous month as a filter.
So I need to add after the last row something like:
PREVIOUSMONTH(SELECTCOLUMNS(RELATEDTABLE('Payment Calendar'),'Payment Calendar'[Date]))
but this syntax is wrong and I also can not use selectcolumns function inside the filter expression in calculatetable function. Adding filter function in the beggining also doesnt work. Also tried chatGTP which suggested wrong code starting with the last row mention earlier:
FinancingContractHeader[Status Groups] = "Settled"
),
YEAR('Payment Calendar'[Date]) = YEAR(TODAY()) &&
MONTH('Payment Calendar'[Date]) = MONTH(TODAY()) - 1
Any suggestion please?
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
7 |
User | Count |
---|---|
13 | |
12 | |
11 | |
11 | |
8 |