Forum Discussion
DAX Calculation
- 7 years ago
Hi esilva32
It certainly looks like it would be easier to do this in the query editor. If you do need to do it in DAX, try this. Create a new calculated table:
TableB = VAR _BaseTable = ADDCOLUMNS ( GENERATE ( DISTINCT ( TableA[Id] ); GENERATESERIES ( CALCULATE ( DISTINCT ( TableA[StartDate] ) ); CALCULATE ( DISTINCT ( TableA[EndDate] ) ) ) ); "TempVal"; CALCULATE ( DISTINCT ( TableA[Value] ) ) ) VAR _Dates = DISTINCT ( SELECTCOLUMNS ( _BaseTable; "Date"; [Value] ) ) VAR _ResTable = ADDCOLUMNS ( _Dates; "Total Value"; SUMX ( _BaseTable; IF ( [Value] = [Date]; [TempVal] ) ) ) RETURN _ResTable - 7 years ago
Hello guys
Thank you for your help. @AIB thank you, worked perfectly, thanks for the help.
Regards, Portugal.
- 7 years ago
Minor modification:
TableB = VAR _BaseTable = ADDCOLUMNS ( GENERATE ( DISTINCT ( TableA[Id] ); GENERATESERIES ( CALCULATE ( DISTINCT ( TableA[StartDate] ) ); MIN ( TODAY (); CALCULATE ( DISTINCT ( TableA[EndDate] ) ) ) ) ); "TempVal"; CALCULATE ( DISTINCT ( TableA[Value] ) ) ) VAR _Dates = DISTINCT ( SELECTCOLUMNS ( _BaseTable; "Date"; [Value] ) ) VAR _ResTable = ADDCOLUMNS ( _Dates; "Total Value"; SUMX ( _BaseTable; IF ( [Value] = [Date]; [TempVal] ) ) ) RETURN _ResTable
Hello people.
I wonder if anyone here has possibilities to help me in PBI.
I need from table A with the fields data_1, time_1, valor_1, moeda_1, dataInt_1 and datahora_1, create a new table B that is a grouping by date_1, moeda_1 and the maximum of datahora_1 and then bring the valor_1 that corresponds to each one of these lines
Hi esilva32
To make the requirement a bit clearer, can you please show what the expected resulting table B would be? BAsed on the table A example you provide
Please mark the question solved when done and consider giving kudos if posts are helpful.
Cheers ![]()
- esilva326 years agoFrequent Visitor
Hello!
The possible result would be what is in the image below.I need to take only a few fields where the field datahora_
1 is maximum.
Thanks