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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
alecw0444
New Member

Custom Column Query Help

Hello,

 

I am trying to get the following code to work but it will not work in Power BI. For reference, I am trying to develop a bar chart that will show a 6 month history of results. Every month has its own file (all are named ThatMonth_Info.... i.e. 'February_Info', 'March_Info', etc). I am trying to make this completely automated, so years down the line it can auto-update the chart.

 

This is the reason for the Date.Month(DateTime.FixedLocalNow()) = 1-6 you see below. If we are in the first six months, I want the data heading to update with the previous year (2018), but if we are in the latter six months, I want the data heading to update with the current year.

 

Currently with the below formula, all my data is populating as 'Jul 2018' (in blue text below)- it's like Power BI is not reading the 'AND' I have (in red below).

 

Any ideas where I am going wrong?

 

 

 

if Date.Month(DateTime.FixedLocalNow()) = 1 or Date.Month(DateTime.FixedLocalNow()) = 2 or Date.Month(DateTime.FixedLocalNow()) = 3 or Date.Month(DateTime.FixedLocalNow()) = 4 or Date.Month(DateTime.FixedLocalNow()) = 5 or Date.Month(DateTime.FixedLocalNow()) = 6 and Text.Contains([Source.Name], "July") then "Jul " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),-1))) else if Text.Contains([Source.Name], "August") then "Aug " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),-1))) else if Text.Contains([Source.Name], "September") then "Sep " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),-1))) else if Text.Contains([Source.Name], "October") then "Oct " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),-1))) else if Text.Contains([Source.Name], "November") then "Nov " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),-1))) else if Text.Contains([Source.Name], "December") then "Dec " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),-1))) else if Text.Contains([Source.Name], "January") then "Jan " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),0))) else if Text.Contains([Source.Name], "February") then "Feb " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),0))) else if Text.Contains([Source.Name], "March") then "Mar " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),0))) else if Text.Contains([Source.Name], "April") then "Apr " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),0))) else if Text.Contains([Source.Name], "May") then "May " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),0))) else if Text.Contains([Source.Name], "June") then "Jun " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),0))) else if Text.Contains([Source.Name], "July") then "Jul " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),0))) else if Text.Contains([Source.Name], "August") then "Aug " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),0))) else if Text.Contains([Source.Name], "September") then "Sep " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),0))) else if Text.Contains([Source.Name], "October") then "Oct " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),0))) else if Text.Contains([Source.Name], "November") then "Nov " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),0))) else if Text.Contains([Source.Name], "December") then "Dec " & Text.From(Date.Year(Date.AddYears(DateTime.FixedLocalNow(),0))) else null

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @alecw0444

As you said,"Every month has its own file", it means there are many tables with month and details, right?

If so, you need merge or append these tables first.

Then to do a 6 month history of results, it may be easy to do with DAX in Power BI.

 

Additionally,

This article contains numerous suggestions and recommendations that will help you get your particular question about Power BI answered quickly and correctly versus seemingly ignored.

 

Best Regards

Maggie

alecw0444
New Member

bump

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.