Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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"
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
17 | |
9 | |
8 | |
7 | |
7 |