Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hello, Your help is appreciated.
I loaded the tables intio the DataModel:
Q1- fVotesAmioun2016
Q2- dCandidatesAmioun2016
Q-3 dRegionAmioun2016
Q4- CandidateCompared //is a variable (Text)(I want it Dymamic, I change the candidate, it changes in the Variable. its codes are:
let
Source = Excel.CurrentWorkbook(){[Name="CandidateCompared_Criteria"]}[Content],
ExtractCell.asText = Source[CandidateCompared_Criteria]{0}
in
ExtractCell.asText
and get the name Get the Name
Linked them in the data model
Measure1:
Study Candidate Votes in Sharqi:=CALCULATE([Tt Votes],fVotesAmioun2016[CandidateEN]=CandidateCompared,fVotesAmioun2016[Region]="Sharqi") giving me error
Study Candidate Votes in Sharqi: #ERROR
If I Hardcode the Candidate "John", "Sam"... it works.
Mease2:
Study Candidate Votes in Sharqi:=CALCULATE([Tt Votes],fVotesAmioun2016[CandidateEN]="John",fVotesAmioun2016[Region]="Sharqi")
Study Candidate Votes in Sharqi-644
Does Excel 2016 Pro Dax does not accept Variable Only HardCode?
How to make the Candidate Dynamic As Vaiable, I change it in excel it flow throught all the rest of tables/Calculation
Later if you want what do you need to upload and how (Basic user) I upload to here Query and DataModel tables?
Thank you
D
CALCULATE(
[Tt Votes],
fVotesAmioun2016[CandidateEN] in VALUES( CandidateCompared ) ,
fVotesAmioun2016[Region]="Sharqi"
)
Your suggestion does not work.
Hi @DSR,
Thanks for reaching out to the Microsoft fabric community forum.
It looks like you are trying to create a dynamic DAX measure that filters votes by region and a candidate name, where the candidate name is coming from an Excel cell. You're also using Power Pivot in Excel 2016. The logic of your measure (CALCULATE([Tt Votes], fVotesAmioun2016[CandidateEN]="John", fVotesAmioun2016[Region]="Sharqi")) is fine, the issue lies in how you're trying to pass the candidate name dynamically.
The variable CandidateCompared you've created in Power Query returns a scalar value, just a single piece of text, like "John". DAX inside a measure doesn't accept that kind of external scalar reference directly. In Excel 2016 specifically, Power Pivot doesn't support passing variables from Power Query into DAX expressions in this way.
You can use a disconnected table and SELECTEDVALUE. First create a small table in Excel (e.g., CandidateCompared_Criteria) with a single column listing candidate names then load it into the Data Model. Do not create a relationship between this table and others. Now add a slicer in your Excel sheet based on this table so you can select a candidate. Then try the this DAX measure "SelectedCandidate := SELECTEDVALUE(CandidateCompared_Criteria[CandidateCompared_Criteria])".
Also rewrite your main measure:
Study Candidate Votes in Sharqi :=
CALCULATE(
[Tt Votes],
fVotesAmioun2016[CandidateEN] = [SelectedCandidate],
fVotesAmioun2016[Region] = "Sharqi"
)
This approach works because DAX can evaluate [SelectedCandidate] as a valid scalar during measure evaluation.
I would also take a moment to thank @Deku, for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Best Regards,
Hammad.
Community Support Team
If this post helps then please mark it as a solution, so that other members find it more quickly.
Thank you.
Hi @DSR,
As we haven’t heard back from you, so just following up to our previous message. I'd like to confirm if you've successfully resolved this issue or if you need further help.
If yes, you are welcome to share your workaround and mark it as a solution so that other users can benefit as well. If you find a reply particularly helpful to you, you can also mark it as a solution.
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.
Hi @DSR,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution so that other community members can find it easily.
Thank you.
Hi @DSR,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
User | Count |
---|---|
13 | |
12 | |
8 | |
8 | |
6 |
User | Count |
---|---|
27 | |
19 | |
13 | |
11 | |
7 |