Forum Discussion
DAX query to create DAX table with average values per month against category
- 4 years ago
NewTable=GENERATE(
NewTable = GENERATE ( SUMMARIZE ( SELECTCOLUMNS ( 'Table', "CurrentMonth", FORMAT ( 'Table'[AuditDate], "MMMM - yyyy" ) ), [CurrentMonth] ), ADDCOLUMNS ( DATATABLE ( "Category", STRING, { { "AverageScore" }, { "AveragePercentage" } } ), "ParamScore", VAR _m = [CurrentMonth] RETURN IF ( [Category] = "AverageScore", FORMAT ( CALCULATE ( AVERAGE ( 'Table'[Score] ), FORMAT ( 'Table'[AuditDate], "MMMM - yyyy" ) = _m ), "" ), FORMAT ( CALCULATE ( AVERAGE ( 'Table'[PercentageStudents] ), FORMAT ( 'Table'[AuditDate], "MMMM - yyyy" ) = _m ), "0%" ) ) ) ) - 4 years ago
Hi wdx223_Daniel This is exactly I was looking for , thankyou for letting me know the approach.I treid to implement is and it worked.Thanks a ton.
- 4 years ago
Here the Score column in input table is in unit of Billion but I want to convert and show the value in Million and put M as a suffix. so 1billion = 1000 million
In ParamScore column, I want to display 0.1875 and 0.75 to 187.5 M and 750 M respectively.
Is it possible and if so please suggest the changes in the above formula?
We require to show the below :-
1. We need to convert from billion to million
2. Add M suffix in the above loop formula
Kind regards
Sameer
- 4 years ago
IF ( [Category] = "AverageScore", FORMAT ( CALCULATE ( AVERAGE ( 'Table'[Score] ), FORMAT ( 'Table'[AuditDate], "MMMM - yyyy" ) = _m )*1000, "0.00M" )
NewTable=GENERATE(
NewTable =
GENERATE (
SUMMARIZE (
SELECTCOLUMNS (
'Table',
"CurrentMonth", FORMAT ( 'Table'[AuditDate], "MMMM - yyyy" )
),
[CurrentMonth]
),
ADDCOLUMNS (
DATATABLE (
"Category", STRING,
{
{ "AverageScore" },
{ "AveragePercentage" }
}
),
"ParamScore",
VAR _m = [CurrentMonth]
RETURN
IF (
[Category] = "AverageScore",
FORMAT (
CALCULATE (
AVERAGE ( 'Table'[Score] ),
FORMAT ( 'Table'[AuditDate], "MMMM - yyyy" ) = _m
),
""
),
FORMAT (
CALCULATE (
AVERAGE ( 'Table'[PercentageStudents] ),
FORMAT ( 'Table'[AuditDate], "MMMM - yyyy" ) = _m
),
"0%"
)
)
)
)
Hi wdx223_Daniel This is exactly I was looking for , thankyou for letting me know the approach.I treid to implement is and it worked.Thanks a ton.