Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Display data based on a condition on year/month column

Hey PBi Community,   This is in corelation with my previous post requesting help. Here is a much clearer picture. I have data spanning multiple years.  The column I have: "week.year" (e.g. contain...
  • Jimmy801's avatar
    Jimmy801
    6 years ago

    Hello Anonymous 

     

    you didn't answer if only -2 year should consideres... however this solution adds a new column in power query and sets true on all current months in every year present.

    Add a new column and put this syntax

    Date.Month(DateTime.FixedLocalNow()) = Number.From(Text.Split(_[week.year],"."){0})

    Here the complete solution

    let
    	Source = #table
    	(
    		{"week.year"},
    		{
    			{"01.2018"},	{"02.2018"},	{"03.2018"},	{"01.2019"},	{"02.2019"},	{"03.2019"},	{"01.2020"}
    		}
    	),
    	AddColumn = Table.AddColumn
    	(
    		Source,
    		"isCurrentMonth",
    		each Date.Month(DateTime.FixedLocalNow()) = Number.From(Text.Split(_[week.year],"."){0})
    	)
    in
    	AddColumn

    Copy paste this code to the advanced editor in a new blank query to see how the solution works. If this solution fits your need, copy and past a part of it and implement it in your query.

    If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
    Kudoes are nice too

    Have fun

    Jimmy