Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi , I am trying try to do M with conditional block. The Idea is, if the report period parameter selected is less than today then it will pull data from Sales_country1 table if it is greater than today then Sales_country2 .
let
Source = Sql.Database("SERVERNAME", "DATABASE"),
#"sales_country1" = Source{[Schema="dbo",Item="sales_country1"]}[Data],
#"sales_country2" = Source{[Schema="dbo",Item="sales_country2"]}[Data],
#"checkperiod" = if @reportperiod <= DateTime.LocalNow()
then #"sales_country1"
else #"sales_country2"
in
#"checkperiod"
The output of this M is not showing the table with data. it shows a text [Table]. I think the issue with IF Then Else statement. I would like to see the table with data but not sure where i am going wrong here.
Any help would be appreciated. Thanks
Hello @Anonymous
the code is perfectly fine. What is Power Query showing if you select the step #"sales_country1" or #"sales_country2"? Where is the parameter "@reportperiod " coming from?
BR
Jimmy
If i do just #"sales_country1" or #"sales_country1" then i get the table with data.
@reportperiod will get value from parameter. Even if I hardcode a value it is still coming up with [TABLE]. The code excutes without error but the output is not in table form. please see image below.
Thanks
Hello @Anonymous
you didn't answer my questions at all
What is your parameter? can you show me the previews of you two tables please
Jimmy
Hi Jimmy,
Thanks for the reply. Even if you take the parameter out of the query, as shown below i still get the Text as output not the table.
let
Source = Sql.Database("SERVERNAME", "DATABASE"),
#"sales_country1" = Source{[Schema="dbo",Item="sales_country1"]}[Data],
#"sales_country2" = Source{[Schema="dbo",Item="sales_country2"]}[Data],
#"checkuser" =
if @SaleManager = "John.Smith"
then #"sales_country1"
else #"sales_country2"
in
#"checkperiod"