Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! 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"
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 6 | |
| 4 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 11 | |
| 10 | |
| 8 | |
| 7 | |
| 7 |