best practices
3 TopicsIF/SWITCH measure performance
Hi, I have a general question about the best way to write if/switch measures. Is any of the following examples (1 and 2) more efficient than the other? 1) if_measure = IF(condition_measure = value1, [measure1], [measure2]) switch_measure = SWITCH(condition_measure, value1, [measure1], value2, [measure2], [measure3]) 2) if_measure = IF(condition_measure = value1, DAX code for measure 1, DAX code for measure 2) switch_measure = SWITCH(condition_measure, value1, DAX code for measure 1, value2, DAX code for measure 2, DAX code for measure 3) Thanks!473Views0likes1CommentKeeping corresponding tier data sources aligned with 3-tier development environments on Report Svr
We have a 3-tier Power BI RS environment (Dev/Test/Prod) and corresponding SQL database environments with an organizational restriction that apps in 1 level can only access data sources in the same level. For example, the Prod app tier can only access ProdSvr\Sales, Test app tier accesses TestSvr\Sales and so on. PBI developers can only publish into the Dev environment and the DBA team controls the promotion process through Test and Prod. Is there anyway to abstract the actual data source identifier and include a parameter so the PBIX doesn't have to be manually changed to match the data source with the corresponding environment? Or is there another approach to support this process?864Views0likes2CommentsHelp with Power BI query optimization
Hi All, I need your help to optimize this power BI query. Currently, the query works very slow (query doesnt return result even after 3 days). let Source = Sql.Database("chvpkw8ahsv117", "hmparsdmd"), Staging_Transactions_Summary = Source{[Schema="Staging",Item="Transactions_Summary"]}[Data], #"Removed Other Columns" = Table.SelectColumns(Staging_Transactions_Summary,{"TransactionDate", "TransactionYYMM", "LocationID", "CardTypeDesc", "FuelTypeDesc", "td_acct_no", "PumpNumber", "IndoorOutDoor", "NFCUsed", "PilotSites", "TransactionCount", "Gallons", "FuelDollars"}), #"Filtered Rows" = Table.SelectRows(#"Removed Other Columns", each ([IndoorOutDoor] = "Outdoor") and ([PilotSites] = "Yes") and ([NFCUsed] = "No")), #"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows",{{"LocationID", Int64.Type}}), #"Sorted Rows" = Table.Sort(#"Changed Type",{{"LocationID", Order.Ascending},{"td_acct_no", Order.Ascending},{"TransactionDate", Order.Ascending}}), #"Reordered Columns" = Table.ReorderColumns(#"Sorted Rows",{"LocationID", "td_acct_no", "TransactionDate", "CardTypeDesc", "FuelTypeDesc", "PumpNumber", "IndoorOutDoor", "NFCUsed", "PilotSites", "TransactionCount", "Gallons", "FuelDollars"}), #"Added Index" = Table.AddIndexColumn(#"Reordered Columns", "Index", 1, 1), #"Merged Queries" = Table.NestedJoin(#"Added Index",{"LocationID", "td_acct_no","Index"},#"Staging Transactions_Summary",{"LocationID", "td_acct_no","Index"},"NewColumn",JoinKind.LeftOuter), #"Expanded NewColumn" = Table.ExpandTableColumn(#"Merged Queries", "NewColumn", {"TransactionDate"}, {"NewColumn.TransactionDate"}), #"Renamed Columns" = Table.RenameColumns(#"Expanded NewColumn",{{"NewColumn.TransactionDate", "NextTransactionDate"}}), #"Filtered Rows1" = Table.SelectRows(#"Renamed Columns", each ([NextTransactionDate] <> null)), #"Added Custom" = Table.AddColumn(#"Filtered Rows1", "DaysFromLastTrans", each if [NextTransactionDate] <> null then Duration.Days(Duration.From([NextTransactionDate]-[TransactionDate])) else null), #"Grouped Rows" = http://itopssqldb.database.windows.net(#"Added Custom", {"LocationID", "TransactionYYMM", "td_acct_no", "CardTypeDesc", "FuelTypeDesc", "IndoorOutDoor", "NFCUsed"}, {{"TransactionCount", each Table.RowCount(_), type number}, {"TotalGallons", each List.Sum([Gallons]), type number}, {"TotalFuelDollars", each List.Sum([FuelDollars]), type number}, {"TotalDays", each List.Sum([DaysFromLastTrans]), type number}}), #"Added Custom1" = Table.AddColumn(#"Grouped Rows", "AvgDaysBetweenTrans", each [TotalDays]/[TransactionCount]) in #"Added Custom1"Solved7.9KViews0likes4Comments