Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
db_2025
Frequent Visitor

Measure to coalesce columns in a matrix visual

Hello,

 

I have data in a fact table that looks like the following, with "Version" and "Month" in separate dimension tables:

VersionMonthSales
ActualJan10000
ActualFeb15000
ActualMar12500
ActualApr14000
January ForecastJan9000
January ForecastFeb13500
January ForecastMar12000
 ...... 
January ForecastDec16000
February ForecastFeb14000
February ForecastMar15000
February ForecastApr16000
 ...... 
February ForecastDec16000
March ForecastMar14000
March ForecastApr15000

 

I am trying to create a measure so that I can use the sum of sales where Version = "Actual Sales" for previous months combined with the sum of sales from the forecast for current and future months in a matrix visual. I've tried a few different measures but the previous months for the "<month> Forecast" columns always remain blank like this:

 

MonthActual SalesJanuary ForecastFebruary ForecastMarch ForecastApril ForecastMay Forecast
Jan100009000    
Feb150001350014000   
Mar12500120001500014000  
Apr1400016000160001500016000 
May 1500015000150001600016000
Jun 1500015000150001500015000
Jul 1500015000150001500015000
Aug 1500015000150001500015000
Sep 1500015000150001500015000
Oct 1600016000160001500015000
Nov 1600016000160001600016000
Dec 1600016000160001600016000
Total51500173500168000152000139000123000

 

I've tried using a few measures including the following with no success:

COALESCE(

   Calculate(Sum(FactTable[Sales]), Filter(DimVersion,DimVersion = "Actual Sales")),

   Calculate(Sum(FactTable[Sales])

)

 

Any help is greatly appreciated. Thanks

 

1 ACCEPTED SOLUTION
v-pgoloju
Community Support
Community Support

Hi @db_2025,

 

Thank you for reaching out to the Microsoft Fabric Forum Community.


And also thanks to @rajendraongole1  for prompt and useful response.

 

Try using modified Dax measure.

Combined Sales =
VAR SelectedVersion = SELECTEDVALUE(DimVersion[Version])
VAR SelectedMonthNumber = SELECTEDVALUE(DimMonth[MonthNumber])

VAR ForecastBaseMonth =
SWITCH(
TRUE(),
CONTAINSSTRING(SelectedVersion, "January"), 1,
CONTAINSSTRING(SelectedVersion, "February"), 2,
CONTAINSSTRING(SelectedVersion, "March"), 3,
CONTAINSSTRING(SelectedVersion, "April"), 4,
CONTAINSSTRING(SelectedVersion, "May"), 5,
CONTAINSSTRING(SelectedVersion, "June"), 6,
CONTAINSSTRING(SelectedVersion, "July"), 7,
CONTAINSSTRING(SelectedVersion, "August"), 8,
CONTAINSSTRING(SelectedVersion, "September"), 9,
CONTAINSSTRING(SelectedVersion, "October"), 10,
CONTAINSSTRING(SelectedVersion, "November"), 11,
CONTAINSSTRING(SelectedVersion, "December"), 12,
BLANK()
)

RETURN
IF(
SelectedMonthNumber < ForecastBaseMonth,
CALCULATE(
SUM(FactTable[Sales]),
'DimVersion'[Version] = "Actual",
REMOVEFILTERS('DimVersion') 
),
CALCULATE(
SUM(FactTable[Sales]),
'DimVersion'[Version] = SelectedVersion
)
)


If this solution helped, please consider marking the response as accepted and giving it a thumbs-up so others can benefit as well.

 

Best regards,
Prasanna Kumar

 

View solution in original post

4 REPLIES 4
v-pgoloju
Community Support
Community Support

Hi @db_2025,

 

Thank you for reaching out to the Microsoft Fabric Forum Community.


And also thanks to @rajendraongole1  for prompt and useful response.

 

Try using modified Dax measure.

Combined Sales =
VAR SelectedVersion = SELECTEDVALUE(DimVersion[Version])
VAR SelectedMonthNumber = SELECTEDVALUE(DimMonth[MonthNumber])

VAR ForecastBaseMonth =
SWITCH(
TRUE(),
CONTAINSSTRING(SelectedVersion, "January"), 1,
CONTAINSSTRING(SelectedVersion, "February"), 2,
CONTAINSSTRING(SelectedVersion, "March"), 3,
CONTAINSSTRING(SelectedVersion, "April"), 4,
CONTAINSSTRING(SelectedVersion, "May"), 5,
CONTAINSSTRING(SelectedVersion, "June"), 6,
CONTAINSSTRING(SelectedVersion, "July"), 7,
CONTAINSSTRING(SelectedVersion, "August"), 8,
CONTAINSSTRING(SelectedVersion, "September"), 9,
CONTAINSSTRING(SelectedVersion, "October"), 10,
CONTAINSSTRING(SelectedVersion, "November"), 11,
CONTAINSSTRING(SelectedVersion, "December"), 12,
BLANK()
)

RETURN
IF(
SelectedMonthNumber < ForecastBaseMonth,
CALCULATE(
SUM(FactTable[Sales]),
'DimVersion'[Version] = "Actual",
REMOVEFILTERS('DimVersion') 
),
CALCULATE(
SUM(FactTable[Sales]),
'DimVersion'[Version] = SelectedVersion
)
)


If this solution helped, please consider marking the response as accepted and giving it a thumbs-up so others can benefit as well.

 

Best regards,
Prasanna Kumar

 

Thank you, this did the trick. And thank you to @rajendraongole1 for your contribution as well!

 

Edit: I noticed an issue. The column totals in the matrix are not correct. They are adding up as the total of the Actual Sales only. Any thoughts on why this might be happening?

 

Edit2: I was able to make the total row calculate correctly by modifying the measure as follows - 

...

RETURN
IF(

HASONEFILTER(DimMonth[MonthNumber]),

IF(
SelectedMonthNumber < ForecastBaseMonth,
CALCULATE(
SUM(FactTable[Sales]),
'DimVersion'[Version] = "Actual",
REMOVEFILTERS('DimVersion') 
),
CALCULATE(
SUM(FactTable[Sales]),
'DimVersion'[Version] = SelectedVersion
)

),

CALCULATE(
SUM(FactTable[Sales]),
'DimVersion'[Version] = "Actual",
REMOVEFILTERS('DimVersion') , 
Selected Month < ForecastDate

) +

CALCULATE(
SUM(FactTable[Sales]),
'DimVersion'[Version] = SelectedVersion
)

)

rajendraongole1
Super User
Super User

Hi @db_2025  - You're on the right track conceptually ,use a Date table with actual dates and use MONTH([Date]).

 

create a measure for combined monthly sales as below:

Referece:

Combined Sales =
VAR SelectedVersion = SELECTEDVALUE(DimVersion[Version])
VAR SelectedMonthNumber = SELECTEDVALUE(DimMonth[MonthNumber])

-- Pull the forecast base month out of the version name
VAR ForecastBaseMonth =
SWITCH(TRUE(),
CONTAINSSTRING(SelectedVersion, "January"), 1,
CONTAINSSTRING(SelectedVersion, "February"), 2,
CONTAINSSTRING(SelectedVersion, "March"), 3,
CONTAINSSTRING(SelectedVersion, "April"), 4,
CONTAINSSTRING(SelectedVersion, "May"), 5,
CONTAINSSTRING(SelectedVersion, "June"), 6,
CONTAINSSTRING(SelectedVersion, "July"), 7,
CONTAINSSTRING(SelectedVersion, "August"), 8,
CONTAINSSTRING(SelectedVersion, "September"), 9,
CONTAINSSTRING(SelectedVersion, "October"), 10,
CONTAINSSTRING(SelectedVersion, "November"), 11,
CONTAINSSTRING(SelectedVersion, "December"), 12,
BLANK()
)

-- Choose Actuals before the forecast month, Forecast from forecast month onwards
RETURN
IF(
SelectedMonthNumber < ForecastBaseMonth,
CALCULATE(
SUM(FactTable[Sales]),
DimVersion[Version] = "Actual"
),
CALCULATE(
SUM(FactTable[Sales]),
DimVersion[Version] = SelectedVersion
)
)

 

Hope this helps , please check

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thanks for your reply. I have tested this and its is not working unfortunately. The logic part of it comparing SelectedMonthNumber to ForecastBaseMonth works fine but I still end up with the blanks for the prior months rather than the Actual Sales. Do you think I need a REMOVEFILTERS or something like that? I think the matrix is taking precedent over the measure's filtering.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.