Forum Discussion
nmck86
8 years agoPost Patron
Joining multiple formulas into one
Hi, I have about 4 formulas that I have created seperately that I would love to join together in one formula. The screenshot below, the column test validation 2 is the end result that I want to s...
nmck86
8 years agoPost Patron
v-xjiin-msft try the below link! Sorry about that.
https://drive.google.com/open?id=1mSopjlD9DtDh_sscTAHXXIDkEj5bpxvE
https://drive.google.com/open?id=1mSopjlD9DtDh_sscTAHXXIDkEj5bpxvE
stretcharm
8 years agoMemorable Member
Can you pivot the Metric fields.
You can then have a calculate the same expression grouped by different attribute/metrics
You can add an index or create a calculated key of Store and Date to join to a master table.
http://radacad.com/pivot-and-unpivot-with-power-bi
- nmck868 years agoPost PatronI thought adding a file that shows the formula in excel would be helpful... the excel file shows the sumif I am trying to get to work in Power BI.
https://drive.google.com/open?id=1HN8Z1COYbUMyT2rptIkHfWd6RupbvHuN
https://docs.google.com/file/d/1-aXWaQbD_2Fh4ts6w51KhjQ53fWfbMFa/edit?usp=docslist_api&filetype=msexcel - stretcharm8 years agoMemorable Member
I've managed to reproduce your results with the following steps
Load the sample data and add a class using a conditional column for Promoters etc .
let
Source = Excel.Workbook(File.Contents("C:\temp\Sample Data Set.xlsx"), null, true),
#"Sample Data_Sheet" = Source{[Item="Sample Data",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(#"Sample Data_Sheet", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"likeliness to recommend", Int64.Type}, {"water quality", Int64.Type}, {"water price", Int64.Type}, {"Weights", type number}}),
#"Added Conditional Column" = Table.AddColumn(#"Changed Type", "Class", each if [likeliness to recommend] = null then "Passive" else if [likeliness to recommend] >= 9 then "Promotors" else if [likeliness to recommend] <= 6 then "Detractors" else "Passive"),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Conditional Column",{{"Class", type text}})
in
#"Changed Type1"Add a new Query for the ratings we want to see. e.g just 0 to 10
let Source = List.Generate(()=>10, each _ > -1, each _ - 1), #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Rating"}}), #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Rating", Int64.Type}}) in #"Changed Type"Add 2 relationships for price and quality to the ratings, but disable them both.
Now add measures to calculate the Price and Quality ratings picking the relationship using USERELATIONSHIP
WaterPrice =
(
CALCULATE (
SUM ( 'Sample Data'[Weights] ),
USERELATIONSHIP ( Ratings[Rating], 'Sample Data'[water price] ),
FILTER ( 'Sample Data', 'Sample Data'[Class] = "Promotors" )
)
- CALCULATE (
SUM ( 'Sample Data'[Weights] ),
USERELATIONSHIP ( Ratings[Rating], 'Sample Data'[water price] ),
FILTER ( 'Sample Data', 'Sample Data'[Class] = "Detractors" )
)
)
/ CALCULATE (
SUM ( 'Sample Data'[Weights] ),
USERELATIONSHIP ( Ratings[Rating], 'Sample Data'[water price] )
)
WaterQuality =
(
CALCULATE (
SUM ( 'Sample Data'[Weights] ),
USERELATIONSHIP ( Ratings[Rating], 'Sample Data'[water quality] ),
FILTER ( 'Sample Data', 'Sample Data'[Class] = "Promotors" )
)
- CALCULATE (
SUM ( 'Sample Data'[Weights] ),
USERELATIONSHIP ( Ratings[Rating], 'Sample Data'[water quality] ),
FILTER ( 'Sample Data', 'Sample Data'[Class] = "Detractors" )
)
)
/ CALCULATE (
SUM ( 'Sample Data'[Weights] ),
USERELATIONSHIP ( Ratings[Rating], 'Sample Data'[water quality] )
)
There are some rows that don't match a rating due to nulls.