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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
flavioaas
New Member

How to return blanks as 0 only for current month?

Hi!
I created a simple data model in order to ilustrate what I want to accomplish.flavioaas_0-1718658699842.png
My goal is to create a bar chart (that will be filtered by a slicer) that shows months in the X axis and the sum of the value column from the fact table.
Since we are currently on June, but the are no instances in the fact table for that month, a simple measure SUM(FactTable[Value]) will return blank for June. Using COALESCE(SUM(FactTable[Value]), 0) will display June, but also all the other months that are not the current one.

flavioaas_0-1718666079230.png

 


How can I return 0 in the visual for the current month while not showing months past the current?

 

1 ACCEPTED SOLUTION
Moetazzahran
Resolver II
Resolver II

Hello @flavioaas , 

If I understand correctly, you want to show case the current month even if it was blank within the bar chart.

M_bar = VAR CurrentMonth = MONTH(TODAY())
VAR CurrentYear = YEAR(TODAY())
RETURN
SWITCH(TRUE(),
    MONTH(MAX('Calendar Table'[Date])) = CurrentMonth && YEAR(MAX('Calendar Table'[Date])) = CurrentYear,
    COALESCE(SUM(FactTable[Value]),0),
        MONTH(MAX('Calendar Table'[Date])) < CurrentMonth && YEAR(MAX('Calendar Table'[Date])) = CurrentYear,
        SUM(FactTable[Value]),
        BLANK()
    )

Please accept it as a solution if it works properly. And you Kudo is much appreciated. 
Thank you.

View solution in original post

1 REPLY 1
Moetazzahran
Resolver II
Resolver II

Hello @flavioaas , 

If I understand correctly, you want to show case the current month even if it was blank within the bar chart.

M_bar = VAR CurrentMonth = MONTH(TODAY())
VAR CurrentYear = YEAR(TODAY())
RETURN
SWITCH(TRUE(),
    MONTH(MAX('Calendar Table'[Date])) = CurrentMonth && YEAR(MAX('Calendar Table'[Date])) = CurrentYear,
    COALESCE(SUM(FactTable[Value]),0),
        MONTH(MAX('Calendar Table'[Date])) < CurrentMonth && YEAR(MAX('Calendar Table'[Date])) = CurrentYear,
        SUM(FactTable[Value]),
        BLANK()
    )

Please accept it as a solution if it works properly. And you Kudo is much appreciated. 
Thank you.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.