Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Greetings,
I'm trying to visualize data based on the results of an if then statement.
CalculateTerm =IF(DISTINCTCOUNT('Player Query'[Years_Played])>3,"LongTerm","ShortTerm")
I'd like to graph the results in a way where count of longterm and count of short term are compared. can't seem to wrap my head around how to accomplish this.
Solved! Go to Solution.
I finally got it! The formula you provided was very close.
Short Term = CALCULATE(
DISTINCTCOUNT('Player Query'[ID]),FILTER(VALUES('Player Query'[ID]),[Years Played]<=3))
I'm still a bit unclear as to how the VALUES function works or why it was necessary for that matter. Thanks for your direction!
Would the following two calculated measures help
Long Term = CALCULATE(DISTINCTCOUNT('Player Query'[Column1]),(FILTER('Player Query','Player Query'[Years Played]>3)))
Short Term = CALCULATE(DISTINCTCOUNT('Player Query'[Column1]),(FILTER('Player Query','Player Query'[Years Played]<=3)))
I finally got it! The formula you provided was very close.
Short Term = CALCULATE(
DISTINCTCOUNT('Player Query'[ID]),FILTER(VALUES('Player Query'[ID]),[Years Played]<=3))
I'm still a bit unclear as to how the VALUES function works or why it was necessary for that matter. Thanks for your direction!
When i export the data, i find that there are 957 rows that are "Long Term". However, when using the Long Term expression you've provided, when i add it to a table it only displays 28 values. It does not appear to be calculating correctly.
These calculated measures are doing a DISTINCTCOUNT. Could it be there are 28 unique values in your 957 rows?
I believe there must be something overall with the way i have things configured.
The measure works as desired when creating a table and listing ID>GamesPlayed > Term. FWIW
Term := if ( games played >3,"Long Term", Short Term")
where
"Games Played" := distinctcount('Player Query' [days played])
You might be close with it. Have you tried dragging that measure to both the axis AND the values area of a chart such as a Bar Chart?
The values area will give you a count.
@Phil_Seamark I'm unable to place the values in the axis or values field and i dont have the slightest idea why!
It was me being lazy. I will look at this later tonight when I have the chance to mock up some data.
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
72 | |
38 | |
31 | |
26 |