Forum Discussion
The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.
Hi Anonymous ,
Please refer to the file now that i have updated successfully.
19 Replies
- Demert
Resolver III
This error is cause of you returning multiple values or a table. In your return statement you are returning an union between two tables. A dax meassure can never return a table. You can check the output of this dax measure in the DAX Query view
This dax query view can return output tables for virtual tables and will help you debug what you need.
To return 1 value from a virtual you need to use a minx, sumx,maxx,... function
- rajendraongole1
Super User
Hi Anonymous - If you'd rather keep your visual tied to the original table and apply filtering through a measure, let me know — we can do it with a TRUE/FALSE filter measure using similar logic
check the below modified logic and let know.
Filtered_ShouldCost =
VAR SelectedSupplier = SELECTEDVALUE(SupplierSlicer_01[NewSupplier])
VAR MaxDateForSupplier =
CALCULATE(
MAX('genai should_cost_data'[should_cost_date]),
FILTER(
ALL('genai should_cost_data'),
'genai should_cost_data'[NewSupplier] = SelectedSupplier
)
)
VAR MinDate = MaxDateForSupplier
VAR MaxDate = EDATE(MaxDateForSupplier, 6)VAR SupplierRows =
FILTER(
ALL('genai should_cost_data'),
'genai should_cost_data'[NewSupplier] = SelectedSupplier
)VAR BlankSupplierRows =
FILTER(
ALL('genai should_cost_data'),
ISBLANK('genai should_cost_data'[NewSupplier]) &&
'genai should_cost_data'[should_cost_date] >= MinDate &&
'genai should_cost_data'[should_cost_date] <= MaxDate
)RETURN
IF (
ISBLANK(SelectedSupplier),
FILTER('genai should_cost_data', FALSE),
UNION(SupplierRows, BlankSupplierRows)
)- AnonymousNot applicable
So, you mean to say that I need not to create a claculated table, where in with the Measure only it should work?
- AnonymousNot applicable
Not working giving me the same error.
- Nasif_Azam
Super User
Hey Anonymous ,
It seems like you're trying to create a table that displays the values for the selected supplier and, for a "BlankSupplier," the values from the next 6 months based on the maximum date for the selected supplier. However, you're facing issues with the DAX expression returning multiple columns when a scalar value is expected.
Try the DAX expression:
Filtered_ShouldCost = VAR SelectedSupplier = SELECTEDVALUE(SupplierSlicer_01[NewSupplier]) VAR MaxDateForSupplier = CALCULATE( MAX('genai should_cost_data'[should_cost_date]), FILTER( ALL('genai should_cost_data'), 'genai should_cost_data'[NewSupplier] = SelectedSupplier ) ) VAR MinDate = MaxDateForSupplier VAR MaxDate = EDATE(MaxDateForSupplier, 6) VAR SupplierRows = FILTER( ALL('genai should_cost_data'), 'genai should_cost_data'[NewSupplier] = SelectedSupplier ) VAR BlankRows = FILTER( ALL('genai should_cost_data'), 'genai should_cost_data'[NewSupplier] = "BlankSupplier" && 'genai should_cost_data'[should_cost_date] >= MinDate && 'genai should_cost_data'[should_cost_date] <= MaxDate ) RETURN IF( ISBLANK(SelectedSupplier), FILTER('genai should_cost_data', FALSE), UNION(SupplierRows, BlankRows) )If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.
Best Regards,
Nasif Azam- AnonymousNot applicable
Thanks for your solution but it is not working and giving me the same error.
- AnonymousNot applicable
Can some one help me here it is bit urgent please !!
- AnonymousNot applicableFiltered_ShouldCost =VAR SelectedSupplier = SELECTEDVALUE(SupplierSlicer_01[NewSupplier])VAR IsBlankSupplier = SelectedSupplier = "BlankSupplier"VAR IsRealSupplier = NOT ISBLANK(SelectedSupplier) && SelectedSupplier <> "BlankSupplier"VAR MaxDateForRealSupplier =CALCULATE(MAX('genai should_cost_data'[should_cost_date]),FILTER(ALL('genai should_cost_data'),'genai should_cost_data'[NewSupplier] = SelectedSupplier))VAR BlankSupplierMinDate = MaxDateForRealSupplierVAR BlankSupplierMaxDate = EDATE(MaxDateForRealSupplier, 6)RETURNSWITCH(TRUE(),// Case 1: BlankSupplier onlyIsBlankSupplier,FILTER(ALL('genai should_cost_data'),'genai should_cost_data'[NewSupplier] = "BlankSupplier"),// Case 2: Real Supplier selectedIsRealSupplier,UNION(FILTER(ALL('genai should_cost_data'),'genai should_cost_data'[NewSupplier] = SelectedSupplier),FILTER(ALL('genai should_cost_data'),'genai should_cost_data'[NewSupplier] = "BlankSupplier"&&'genai should_cost_data'[should_cost_date] >= BlankSupplierMinDate&&'genai should_cost_data'[should_cost_date] <= BlankSupplierMaxDate)),// Case 3: Nothing selectedROW("NewSupplier", BLANK(), "Should_Cost_date", BLANK(), "Should_cost", BLANK()))I tried this way as well, bust still getting the same error...
- v-echaithra
Community Support
Hi Anonymous ,
Thanks for reaching out to Microsoft Community and explaining your requirement. To help reproduce the issue and provide an accurate solution, could you please share a small sample of your dataset and the expected output?
Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Best Regards,
Chaithra E.- AnonymousNot applicable
Hello v-Echaithra,
Please find the below Data Set and Expected Output
Supplier CostDate Cost CostDateFormatted ABC Ltd 01-01-2024 71.73 01-01-2024 ABC Ltd 01-02-2024 45.96 02-01-2024 ABC Ltd 01-03-2024 17.83 03-01-2024 ABC Ltd 01-04-2024 74.81 04-01-2024 ABC Ltd 01-05-2024 66.14 05-01-2024 ABC Ltd 01-06-2024 22.21 06-01-2024 ABC Ltd 01-07-2024 75.96 07-01-2024 ABC Ltd 01-08-2024 12.66 08-01-2024 ABC Ltd 01-09-2024 89.3 09-01-2024 ABC Ltd 01-10-2024 39.83 10-01-2024 ABC Ltd 01-11-2024 29.49 11-01-2024 ABC Ltd 01-12-2024 27.9 12-01-2024 XYZ Corp 01-01-2024 96.51 01-01-2024 XYZ Corp 01-02-2024 11.64 02-01-2024 XYZ Corp 01-03-2024 14.85 03-01-2024 XYZ Corp 01-04-2024 22.58 04-01-2024 XYZ Corp 01-05-2024 93.1 05-01-2024 XYZ Corp 01-06-2024 15.75 06-01-2024 XYZ Corp 01-07-2024 61.56 07-01-2024 XYZ Corp 01-08-2024 11.03 08-01-2024 XYZ Corp 01-09-2024 87.13 09-01-2024 XYZ Corp 01-10-2024 32.12 10-01-2024 XYZ Corp 01-11-2024 22.68 11-01-2024 XYZ Corp 01-12-2024 16.55 12-01-2024 BlankSupplier 01-02-2024 51.92 02-01-2024 BlankSupplier 01-03-2024 74.21 03-01-2024 BlankSupplier 01-04-2024 51.34 04-01-2024 BlankSupplier 01-05-2024 66.48 05-01-2024 BlankSupplier 01-06-2024 65.38 06-01-2024 BlankSupplier 01-07-2024 61.02 07-01-2024 Expected Output :
Selected Supplier ABC Ltd Supplier CostDate Cost ABC Ltd 01-01-2024 71.73 ABC Ltd 01-02-2024 45.96 ABC Ltd 01-03-2024 17.83 ABC Ltd 01-04-2024 74.81 ABC Ltd 01-05-2024 66.14 ABC Ltd 01-06-2024 22.21 ABC Ltd 01-07-2024 75.96 ABC Ltd 01-08-2024 12.66 ABC Ltd 01-09-2024 89.3 ABC Ltd 01-10-2024 39.83 ABC Ltd 01-11-2024 29.49 ABC Ltd 01-12-2024 27.9 BlankSupplier 01-02-2024 51.92 BlankSupplier 01-03-2024 74.21 BlankSupplier 01-04-2024 51.34 BlankSupplier 01-05-2024 66.48 BlankSupplier 01-06-2024 65.38 BlankSupplier 01-07-2024 61.02 As Max Date for ABC Ltd is 01-12-2024ABC LTd Sum of(Should cost) = 573.82 Blank Supplier Max date of ABC LTd from here Next 6 month entries to be considered 370.35 Regards,
Anup
- Ashish_Mathur
Super User
Hi,
If you select 1-12-2024, then the next six months are from 1-1-2025 to 1-6-2025. the dates of the blank supplier are not in that range. Also, for the seected supplier why have you added all the numbers?
- v-echaithra
Community Support
Hi Anonymous ,
Thanks for providing the sample data.
Create a Disconnected Table for Supplier Slicer.
Go to Modeling > New Table:
SupplierList =
DISTINCT (
FILTER (
VALUES(ShouldCostData[Supplier]),
ShouldCostData[Supplier] <> "BlankSupplier"))Add a Slicer using this table.
Use SupplierList[Supplier] in the slicer.Then create a Measure (BlankSupplier_measure)
BlankSupplier_measure =
VAR SelectedSupplier = SELECTEDVALUE(SupplierList[Supplier])VAR MinDate =
CALCULATE (
MIN (ShouldCostData[CostDate]),
FILTER (
ALL (ShouldCostData),
ShouldCostData[Supplier] = SelectedSupplier
)
)
VAR EndDate = EDATE(MinDate, 6)RETURN
CALCULATE (
COUNTROWS (ShouldCostData),
FILTER (
ShouldCostData,
(ShouldCostData[Supplier] = SelectedSupplier) ||
(ShouldCostData[Supplier] = "BlankSupplier" &&
ShouldCostData[CostDate] >= MinDate &&
ShouldCostData[CostDate] < EndDate )))
Now you create a Table visual and add this measure to your table visual.Apply a visual-level filter: BlankSupplier_measure > 0
Please refer to the solution provided in the pbix file.
If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.
Thanks,
Chaithra E.- AnonymousNot applicable
Thank you!!
But this folder is empty 😞
Regards,
Anup
- v-echaithra
Community Support
Hi Anonymous ,
Please refer to the file now that i have updated successfully.
- v-echaithra
Community Support
Hi Anonymous ,
May I ask if you have gotten this issue resolved?
If it is solved, please mark the helpful reply or share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.
Regards,
Chaithra. - v-echaithra
Community Support
Hi Anonymous ,
We’d like to follow up regarding the recent concern. Kindly confirm whether the issue has been resolved, or if further assistance is still required. We are available to support you and are committed to helping you reach a resolution.
Thank you for your patience and look forward to hearing from you.
Best Regards,
Chaithra E. - v-echaithra
Community Support
Hi Anonymous ,
We would like to confirm if you've successfully resolved this issue or if you need further help. If you still have any questions or need more support, please feel free to let us know. We are more than happy to continue to help you.Thank you for your patience and look forward to hearing from you.
Best Regards,
Chaithra E.- AnonymousNot applicable
Hello, Thanks for your inputs !! I was bit busyin some other work and could not verify the same. I will check and update here.
Thank you!