Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.
Hi,
If i have 2 or more Bike names and and i want to select the prize for last month of the selected period.
period | Bike prize | Name |
1.2023 | 2,35,599 | Royal Enfield |
2.2023 | 2,34,999 | Royal Enfield |
3.2023 | 2,35,999 | Royal Enfield |
4.2023 | 2,33,599 | Royal Enfield |
5.2023 | 2,35,499 | Royal Enfield |
6.2023 | 2,36,999 | Royal Enfield |
7.2023 | 2,36,909 | Royal Enfield |
8.2023 | 2,36,999 | Royal Enfield |
1.2023 | 1,28,478 | BMW |
2.2023 | 1,28,999 | BMW |
3.2023 | 1,26,463 | BMW |
4.2023 | 1,23,599 | BMW |
5.2023 | 1,26,849 | BMW |
6.2023 | 1,26,544 | BMW |
7.2023 | 1,27,999 | BMW |
8.2023 | 1,25,899 | BMW |
For Example:- If i selected Royal enfield bike and the period is between 1.2023 to 5.2023 then the out put should be the last month of selected period.
5.2023 | 2,35,499 | Royal Enfield |
Can someone help me to get the DAX formula for the above issue.
Thanks in advance.
Solved! Go to Solution.
It's a two step process. First find the max month of the selected period, then compute the value (via sum or max etc) for that month.
Try something like:
Last Month Bike Prize = LASTNONBLANKVALUE(Table[period],MIN(Table[Bike prize]))
Hi @Anonymous ,
According to your description, here are my steps you can follow as a solution.
(1)My test data is the same as yours.
(2) Click "transform data" to enter the power query, click "Advanced Editor" to copy and paste the following code. Please check the steps in the right hand column.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jZA9C8JADIb/itwcpL18XG4VHLu4OBwdBBWEorP/3lK5mogHboHnyZvwlhL6bewiBggRkIFznsfD43maNvv79XaZzmGEEqKxCHLDQpfVsshY2LzILosalhhLmheTt7rflv6VtfbVQ1SgpPO4G46+pYW9EypDwwRI0DAyrDZSGbs9JcvEMSYyLBmWvn5Rwxj0w8YX", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [period = _t, #"Bike prize" = _t, Name = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"period", type number}, {"Bike prize", Int64.Type}, {"Name", type text}}),
#"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "period", "period - Copy"),
#"Split Column by Delimiter" = Table.SplitColumn(Table.TransformColumnTypes(#"Duplicated Column", {{"period - Copy", type text}}, "en-US"), "period - Copy", Splitter.SplitTextByDelimiter(".", QuoteStyle.Csv), {"period - Copy.1", "period - Copy.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"period - Copy.1", Int64.Type}, {"period - Copy.2", Int64.Type}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"period - Copy.2", "Year"}, {"period - Copy.1", "Month"}}),
#"Added Custom" = Table.AddColumn(#"Renamed Columns", "Custom", each 1),
#"Renamed Columns1" = Table.RenameColumns(#"Added Custom",{{"Custom", "Day"}}),
#"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Renamed Columns1", {{"Year", type text}, {"Month", type text}, {"Day", type text}}, "en-US"),{"Year", "Month", "Day"},Combiner.CombineTextByDelimiter("-", QuoteStyle.None),"Merged"),
#"Changed Type2" = Table.TransformColumnTypes(#"Merged Columns",{{"Merged", type date}}),
#"Renamed Columns2" = Table.RenameColumns(#"Changed Type2",{{"Merged", "Year-Month"}}),
#"Changed Type3" = Table.TransformColumnTypes(#"Renamed Columns2",{{"period", type text}})
in
#"Changed Type3"
(3)We can create a measures.
Flag = IF(YEAR(MAX('Table'[Year-Month]))=YEAR(MAXX(ALLSELECTED('Table'),'Table'[Year-Month])) && MONTH(MAX('Table'[Year-Month]))=MONTH(MAXX(ALLSELECTED('Table'),'Table'[Year-Month])),1,0)
Bike prize Measure = CALCULATE(MAX('Table'[Bike prize]),FILTER(ALLSELECTED('Table'),[Flag]=1))
(4)Place [Flag]=1 on the visual object filter and then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
It's a two step process. First find the max month of the selected period, then compute the value (via sum or max etc) for that month.
Check out the November 2023 Power BI update to learn about new features.
Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.
Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!