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.
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
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
bump
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
111 | |
92 | |
84 | |
66 |